Skip to content

Commit

Permalink
thermal: core: Stop polling DISABLED thermal devices
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>
Reviewed-by: Amit Kucheria <[email protected]>
Signed-off-by: Daniel Lezcano <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
andrzejtp authored and dlezcano committed Jun 29, 2020
1 parent bbcf90c commit b56bdff
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions drivers/thermal/thermal_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,22 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
cancel_delayed_work(&tz->poll_queue);
}

static inline bool should_stop_polling(struct thermal_zone_device *tz)
{
return !thermal_zone_device_is_enabled(tz);
}

static void monitor_thermal_zone(struct thermal_zone_device *tz)
{
bool stop;

stop = should_stop_polling(tz);

mutex_lock(&tz->lock);

if (tz->passive)
if (!stop && tz->passive)
thermal_zone_device_set_polling(tz, tz->passive_delay);
else if (tz->polling_delay)
else if (!stop && tz->polling_delay)
thermal_zone_device_set_polling(tz, tz->polling_delay);
else
thermal_zone_device_set_polling(tz, 0);
Expand Down Expand Up @@ -517,6 +526,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
{
int count;

if (should_stop_polling(tz))
return;

if (atomic_read(&in_suspend))
return;

Expand Down

0 comments on commit b56bdff

Please sign in to comment.