]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: core: Check passive delay in monitor_thermal_zone()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 26 Aug 2024 16:32:36 +0000 (18:32 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 5 Sep 2024 10:33:21 +0000 (12:33 +0200)
The only case in which thermal_zone_device_set_polling() is called
with its second argument equal to zero is when passive cooling is
under way and passive_delay_jiffies is 0, which only happens when
the given thermal zone is not polled at all.

If monitor_thermal_zone() is modified to check passive_delay_jiffies
directly, the check of the thermal_zone_device_set_polling() second
argument against 0 can be dropped and a passive_delay check can be
dropped from thermal_zone_device_register_with_trips(), so change the
code accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2004353.PYKUYFuaPT@rjwysocki.net
drivers/thermal/thermal_core.c

index 2f11d271300a096ab8e17db2e0d58b7e1155c996..dd9b303a98f512adb4e6f93f39c634ab7bebc934 100644 (file)
@@ -323,11 +323,6 @@ static void thermal_zone_broken_disable(struct thermal_zone_device *tz)
 static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
                                            unsigned long delay)
 {
-       if (!delay) {
-               cancel_delayed_work(&tz->poll_queue);
-               return;
-       }
-
        if (delay > HZ)
                delay = round_jiffies_relative(delay);
 
@@ -364,7 +359,7 @@ static void thermal_zone_recheck(struct thermal_zone_device *tz, int error)
 
 static void monitor_thermal_zone(struct thermal_zone_device *tz)
 {
-       if (tz->passive > 0)
+       if (tz->passive > 0 && tz->passive_delay_jiffies)
                thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
        else if (tz->polling_delay_jiffies)
                thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
@@ -1411,13 +1406,8 @@ thermal_zone_device_register_with_trips(const char *type,
        if (num_trips > 0 && !trips)
                return ERR_PTR(-EINVAL);
 
-       if (polling_delay) {
-               if (passive_delay > polling_delay)
-                       return ERR_PTR(-EINVAL);
-
-               if (!passive_delay)
-                       passive_delay = polling_delay;
-       }
+       if (polling_delay && passive_delay > polling_delay)
+               return ERR_PTR(-EINVAL);
 
        if (!thermal_class)
                return ERR_PTR(-ENODEV);