]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:52:50 +0000 (13:52 +0100)
[ Upstream commit 54fccad63ec88924db828df6fc0648930bccf345 ]

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
Stable-dep-of: 7837fa8115e0 ("thermal: core: Mark thermal zones as initializing to start with")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h
drivers/thermal/thermal_sysfs.c

index 2f9128cf55e920abcbc16d4fd169d8f3e2bac23c..468a0dae8c497ba433253edcfab6c391661ae5ab 100644 (file)
@@ -553,10 +553,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
        LIST_HEAD(way_up_list);
        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);
@@ -651,13 +648,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 57fff8bd57611dd489d41a90d72acd5eb352cce1..e93a7641736ed8dc850b6c4a9535fa3df6266cc6 100644 (file)
@@ -293,7 +293,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 d628dd67be5ccf700e1fe6ffc8975d84ae7f5c9e..21f73a230c53e3ebd7ba3561b4d767ad51bc8fe7 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");