@@ -305,7 +305,7 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
cancel_delayed_work(&tz->poll_queue);
}
-static void monitor_thermal_zone(struct thermal_zone_device *tz)
+void monitor_thermal_zone(struct thermal_zone_device *tz)
{
mutex_lock(&tz->lock);
@@ -89,6 +89,8 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
unsigned long new_state) {}
#endif /* CONFIG_THERMAL_STATISTICS */
+void monitor_thermal_zone(struct thermal_zone_device *tz);
+
/* device tree support */
#ifdef CONFIG_THERMAL_OF
int of_parse_thermal_zones(void);
@@ -62,11 +62,14 @@ mode_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
+ enum thermal_device_mode old_mode, mode;
int result;
if (!tz->ops->set_mode)
return -EPERM;
+ old_mode = thermal_zone_device_get_mode(tz);
+
if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
result = thermal_zone_device_enable(tz);
else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
@@ -77,6 +80,10 @@ mode_store(struct device *dev, struct device_attribute *attr,
if (result)
return result;
+ mode = thermal_zone_device_get_mode(tz);
+ if (mode != old_mode)
+ monitor_thermal_zone(tz);
+
return count;
}
Mode changing might imply a need to stop/start polling the device. monitor_thermal_zone() when mode changes. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- drivers/thermal/thermal_core.c | 2 +- drivers/thermal/thermal_core.h | 2 ++ drivers/thermal/thermal_sysfs.c | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-)