]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: core: Drop thermal_zone_device_is_enabled()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 26 Aug 2024 16:37:16 +0000 (18:37 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 5 Sep 2024 10:33:24 +0000 (12:33 +0200)
There are only two callers of thermal_zone_device_is_enabled()
and one of them call is under the zone lock and the other one uses
lockdep_assert_held() on that lock.  Thus the lockdep_assert_held()
in thermal_zone_device_is_enabled() is redundant and it could be
dropped, but then the function would merely become a wrapper around
a simple tz->mode check that is more convenient to do directly.

Accordingly, drop thermal_zone_device_is_enabled() altogether and update
its callers to check tz->mode directly as appropriate.

While at it, combine the tz->mode and tz->suspended checks in
__thermal_zone_device_update() because they are of a similar category
and if any of them evaluates to "true", the outcome is the same.

No intentinal functional impact.

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

index dd9b303a98f512adb4e6f93f39c634ab7bebc934..073d02e21352e69c183394b0c396449326a6625b 100644 (file)
@@ -547,10 +547,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
        int low = -INT_MAX, high = INT_MAX;
        int temp, ret;
 
-       if (tz->suspended)
-               return;
-
-       if (!thermal_zone_device_is_enabled(tz))
+       if (tz->suspended || tz->mode != THERMAL_DEVICE_ENABLED)
                return;
 
        ret = __thermal_zone_get_temp(tz, &temp);
@@ -652,13 +649,6 @@ int thermal_zone_device_disable(struct thermal_zone_device *tz)
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_disable);
 
-int thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
-{
-       lockdep_assert_held(&tz->lock);
-
-       return tz->mode == THERMAL_DEVICE_ENABLED;
-}
-
 static bool thermal_zone_is_present(struct thermal_zone_device *tz)
 {
        return !list_empty(&tz->node);
index 9b19b614a1bc3143e99e26e0cc0448324ef29c30..50b858aa173a070e6cc993efd246b9c9449ff277 100644 (file)
@@ -284,7 +284,4 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
                                    unsigned long new_state) {}
 #endif /* CONFIG_THERMAL_STATISTICS */
 
-/* device tree support */
-int thermal_zone_device_is_enabled(struct thermal_zone_device *tz);
-
 #endif /* __THERMAL_CORE_H__ */
index 197ae12624661f899b35bc607475e87d7e9414de..1838aa729bb50aa2acba1d0abac8654f1d30e023 100644 (file)
@@ -53,7 +53,7 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf)
        int enabled;
 
        mutex_lock(&tz->lock);
-       enabled = thermal_zone_device_is_enabled(tz);
+       enabled = tz->mode == THERMAL_DEVICE_ENABLED;
        mutex_unlock(&tz->lock);
 
        return sprintf(buf, "%s\n", enabled ? "enabled" : "disabled");