aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_sys.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 6f8d8f971212..13c72c629329 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/slab.h>
29#include <linux/kdev_t.h> 30#include <linux/kdev_t.h>
30#include <linux/idr.h> 31#include <linux/idr.h>
31#include <linux/thermal.h> 32#include <linux/thermal.h>
@@ -225,6 +226,12 @@ passive_store(struct device *dev, struct device_attribute *attr,
225 if (!sscanf(buf, "%d\n", &state)) 226 if (!sscanf(buf, "%d\n", &state))
226 return -EINVAL; 227 return -EINVAL;
227 228
229 /* sanity check: values below 1000 millicelcius don't make sense
230 * and can cause the system to go into a thermal heart attack
231 */
232 if (state && state < 1000)
233 return -EINVAL;
234
228 if (state && !tz->forced_passive) { 235 if (state && !tz->forced_passive) {
229 mutex_lock(&thermal_list_lock); 236 mutex_lock(&thermal_list_lock);
230 list_for_each_entry(cdev, &thermal_cdev_list, node) { 237 list_for_each_entry(cdev, &thermal_cdev_list, node) {
@@ -235,6 +242,8 @@ passive_store(struct device *dev, struct device_attribute *attr,
235 cdev); 242 cdev);
236 } 243 }
237 mutex_unlock(&thermal_list_lock); 244 mutex_unlock(&thermal_list_lock);
245 if (!tz->passive_delay)
246 tz->passive_delay = 1000;
238 } else if (!state && tz->forced_passive) { 247 } else if (!state && tz->forced_passive) {
239 mutex_lock(&thermal_list_lock); 248 mutex_lock(&thermal_list_lock);
240 list_for_each_entry(cdev, &thermal_cdev_list, node) { 249 list_for_each_entry(cdev, &thermal_cdev_list, node) {
@@ -245,17 +254,12 @@ passive_store(struct device *dev, struct device_attribute *attr,
245 cdev); 254 cdev);
246 } 255 }
247 mutex_unlock(&thermal_list_lock); 256 mutex_unlock(&thermal_list_lock);
257 tz->passive_delay = 0;
248 } 258 }
249 259
250 tz->tc1 = 1; 260 tz->tc1 = 1;
251 tz->tc2 = 1; 261 tz->tc2 = 1;
252 262
253 if (!tz->passive_delay)
254 tz->passive_delay = 1000;
255
256 if (!tz->polling_delay)
257 tz->polling_delay = 10000;
258
259 tz->forced_passive = state; 263 tz->forced_passive = state;
260 264
261 thermal_zone_device_update(tz); 265 thermal_zone_device_update(tz);
@@ -374,7 +378,7 @@ thermal_cooling_device_cur_state_store(struct device *dev,
374 if (!sscanf(buf, "%ld\n", &state)) 378 if (!sscanf(buf, "%ld\n", &state))
375 return -EINVAL; 379 return -EINVAL;
376 380
377 if (state < 0) 381 if ((long)state < 0)
378 return -EINVAL; 382 return -EINVAL;
379 383
380 result = cdev->ops->set_cur_state(cdev, state); 384 result = cdev->ops->set_cur_state(cdev, state);
@@ -502,6 +506,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
502 tz->temp_input.attr.attr.name = tz->temp_input.name; 506 tz->temp_input.attr.attr.name = tz->temp_input.name;
503 tz->temp_input.attr.attr.mode = 0444; 507 tz->temp_input.attr.attr.mode = 0444;
504 tz->temp_input.attr.show = temp_input_show; 508 tz->temp_input.attr.show = temp_input_show;
509 sysfs_attr_init(&tz->temp_input.attr.attr);
505 result = device_create_file(hwmon->device, &tz->temp_input.attr); 510 result = device_create_file(hwmon->device, &tz->temp_input.attr);
506 if (result) 511 if (result)
507 goto unregister_hwmon_device; 512 goto unregister_hwmon_device;
@@ -514,6 +519,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
514 tz->temp_crit.attr.attr.name = tz->temp_crit.name; 519 tz->temp_crit.attr.attr.name = tz->temp_crit.name;
515 tz->temp_crit.attr.attr.mode = 0444; 520 tz->temp_crit.attr.attr.mode = 0444;
516 tz->temp_crit.attr.show = temp_crit_show; 521 tz->temp_crit.attr.show = temp_crit_show;
522 sysfs_attr_init(&tz->temp_crit.attr.attr);
517 result = device_create_file(hwmon->device, 523 result = device_create_file(hwmon->device,
518 &tz->temp_crit.attr); 524 &tz->temp_crit.attr);
519 if (result) 525 if (result)
@@ -722,6 +728,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
722 goto release_idr; 728 goto release_idr;
723 729
724 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id); 730 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id);
731 sysfs_attr_init(&dev->attr.attr);
725 dev->attr.attr.name = dev->attr_name; 732 dev->attr.attr.name = dev->attr_name;
726 dev->attr.attr.mode = 0444; 733 dev->attr.attr.mode = 0444;
727 dev->attr.show = thermal_cooling_device_trip_point_show; 734 dev->attr.show = thermal_cooling_device_trip_point_show;
@@ -1016,6 +1023,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
1016 thermal_zone_device_set_polling(tz, tz->passive_delay); 1023 thermal_zone_device_set_polling(tz, tz->passive_delay);
1017 else if (tz->polling_delay) 1024 else if (tz->polling_delay)
1018 thermal_zone_device_set_polling(tz, tz->polling_delay); 1025 thermal_zone_device_set_polling(tz, tz->polling_delay);
1026 else
1027 thermal_zone_device_set_polling(tz, 0);
1019 mutex_unlock(&tz->lock); 1028 mutex_unlock(&tz->lock);
1020} 1029}
1021EXPORT_SYMBOL(thermal_zone_device_update); 1030EXPORT_SYMBOL(thermal_zone_device_update);