diff options
Diffstat (limited to 'drivers/thermal/thermal_sys.c')
-rw-r--r-- | drivers/thermal/thermal_sys.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 6f8d8f971212..5066de5cfc0c 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
@@ -225,6 +225,12 @@ passive_store(struct device *dev, struct device_attribute *attr, | |||
225 | if (!sscanf(buf, "%d\n", &state)) | 225 | if (!sscanf(buf, "%d\n", &state)) |
226 | return -EINVAL; | 226 | return -EINVAL; |
227 | 227 | ||
228 | /* sanity check: values below 1000 millicelcius don't make sense | ||
229 | * and can cause the system to go into a thermal heart attack | ||
230 | */ | ||
231 | if (state && state < 1000) | ||
232 | return -EINVAL; | ||
233 | |||
228 | if (state && !tz->forced_passive) { | 234 | if (state && !tz->forced_passive) { |
229 | mutex_lock(&thermal_list_lock); | 235 | mutex_lock(&thermal_list_lock); |
230 | list_for_each_entry(cdev, &thermal_cdev_list, node) { | 236 | list_for_each_entry(cdev, &thermal_cdev_list, node) { |
@@ -235,6 +241,8 @@ passive_store(struct device *dev, struct device_attribute *attr, | |||
235 | cdev); | 241 | cdev); |
236 | } | 242 | } |
237 | mutex_unlock(&thermal_list_lock); | 243 | mutex_unlock(&thermal_list_lock); |
244 | if (!tz->passive_delay) | ||
245 | tz->passive_delay = 1000; | ||
238 | } else if (!state && tz->forced_passive) { | 246 | } else if (!state && tz->forced_passive) { |
239 | mutex_lock(&thermal_list_lock); | 247 | mutex_lock(&thermal_list_lock); |
240 | list_for_each_entry(cdev, &thermal_cdev_list, node) { | 248 | list_for_each_entry(cdev, &thermal_cdev_list, node) { |
@@ -245,17 +253,12 @@ passive_store(struct device *dev, struct device_attribute *attr, | |||
245 | cdev); | 253 | cdev); |
246 | } | 254 | } |
247 | mutex_unlock(&thermal_list_lock); | 255 | mutex_unlock(&thermal_list_lock); |
256 | tz->passive_delay = 0; | ||
248 | } | 257 | } |
249 | 258 | ||
250 | tz->tc1 = 1; | 259 | tz->tc1 = 1; |
251 | tz->tc2 = 1; | 260 | tz->tc2 = 1; |
252 | 261 | ||
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; | 262 | tz->forced_passive = state; |
260 | 263 | ||
261 | thermal_zone_device_update(tz); | 264 | thermal_zone_device_update(tz); |
@@ -374,7 +377,7 @@ thermal_cooling_device_cur_state_store(struct device *dev, | |||
374 | if (!sscanf(buf, "%ld\n", &state)) | 377 | if (!sscanf(buf, "%ld\n", &state)) |
375 | return -EINVAL; | 378 | return -EINVAL; |
376 | 379 | ||
377 | if (state < 0) | 380 | if ((long)state < 0) |
378 | return -EINVAL; | 381 | return -EINVAL; |
379 | 382 | ||
380 | result = cdev->ops->set_cur_state(cdev, state); | 383 | result = cdev->ops->set_cur_state(cdev, state); |
@@ -1016,6 +1019,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) | |||
1016 | thermal_zone_device_set_polling(tz, tz->passive_delay); | 1019 | thermal_zone_device_set_polling(tz, tz->passive_delay); |
1017 | else if (tz->polling_delay) | 1020 | else if (tz->polling_delay) |
1018 | thermal_zone_device_set_polling(tz, tz->polling_delay); | 1021 | thermal_zone_device_set_polling(tz, tz->polling_delay); |
1022 | else | ||
1023 | thermal_zone_device_set_polling(tz, 0); | ||
1019 | mutex_unlock(&tz->lock); | 1024 | mutex_unlock(&tz->lock); |
1020 | } | 1025 | } |
1021 | EXPORT_SYMBOL(thermal_zone_device_update); | 1026 | EXPORT_SYMBOL(thermal_zone_device_update); |