@@ -378,6 +378,8 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
.bind = of_thermal_bind,
.unbind = of_thermal_unbind,
+
+ .ops_of_thermal = true,
};
/*** sensor API ***/
@@ -84,6 +84,18 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
goto exit;
+ if (tz->ops->ops_of_thermal) {
+ enum thermal_device_mode mode;
+
+ ret = tz->ops->get_mode(tz, &mode);
+ if (ret)
+ goto exit;
+
+ if (mode == THERMAL_DEVICE_DISABLED)
+ dev_warn_once(&tz->device,
+ "trying to read out disabled thermal zone\n");
+ }
+
mutex_lock(&tz->lock);
ret = tz->ops->get_temp(tz, temp);
@@ -115,6 +115,7 @@ struct thermal_zone_device_ops {
enum thermal_trip_type);
bool set_mode_skip_check;
+ bool ops_of_thermal;
};
struct thermal_cooling_device_ops {
* Add ops_of_thermal flag to struct thermal_zone_device_ops and set it in of-thermal.c. * Add checking sensor mode for drivers using of-thermal.c to thermal_zone_get_temp() (print a warning if sensor is disabled). Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> --- drivers/thermal/of-thermal.c | 2 ++ drivers/thermal/thermal_helpers.c | 12 ++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 15 insertions(+)