Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: core: Stop polling DISABLED thermal devices

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.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200629122925.21729-10-andrzej.p@collabora.com

authored by

Andrzej Pietrasiewicz and committed by
Daniel Lezcano
b56bdff7 bbcf90c0

+14 -2
+14 -2
drivers/thermal/thermal_core.c
··· 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); ··· 525 516 enum thermal_notify_event event) 526 517 { 527 518 int count; 519 + 520 + if (should_stop_polling(tz)) 521 + return; 528 522 529 523 if (atomic_read(&in_suspend)) 530 524 return;