Polling DISABLED devices is not desired, as all such "disabled" devices are meant to be handled by userspace. This patch introduces and uses should_stop_polling() to decide whether the device should be polled or not.
Unified · Split
| @@ -301,13 +301,22 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, · 300 unmodified lines | ||
| 301 | 301 | cancel_delayed_work(&tz->poll_queue); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | +static inline bool should_stop_polling(struct thermal_zone_device *tz) | |
| 305 | +{ | |
| 306 | + return !thermal_zone_device_is_enabled(tz); | |
| 307 | +} | |
| 308 | + | |
| 304 | 309 | static void monitor_thermal_zone(struct thermal_zone_device *tz) |
| 305 | 310 | { |
| 311 | + bool stop; | |
| 312 | + | |
| 313 | + stop = should_stop_polling(tz); | |
| 314 | + | |
| 306 | 315 | mutex_lock(&tz->lock); |
| 307 | 316 | |
| 308 | − if (tz->passive) | |
| 317 | + if (!stop && tz->passive) | |
| 309 | 318 | thermal_zone_device_set_polling(tz, tz->passive_delay); |
| 310 | − else if (tz->polling_delay) | |
| 319 | + else if (!stop && tz->polling_delay) | |
| 311 | 320 | thermal_zone_device_set_polling(tz, tz->polling_delay); |
| 312 | 321 | else |
| 313 | 322 | thermal_zone_device_set_polling(tz, 0); |
| @@ -517,6 +526,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, · 203 unmodified lines | ||
| 517 | 526 | { |
| 518 | 527 | int count; |
| 519 | 528 | |
| 529 | + if (should_stop_polling(tz)) | |
| 530 | + return; | |
| 531 | + | |
| 520 | 532 | if (atomic_read(&in_suspend)) |
| 521 | 533 | return; |
| 522 | 534 | |