aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_sysfs.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2022-08-05 17:38:34 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2022-08-17 14:09:39 +0200
commita930da9bf583b2add01fb0e086913664dadaffd0 (patch)
treed4ef64b482bf616f417fffcbbdc60624397cc792 /drivers/thermal/thermal_sysfs.c
parentthermal/core: Move the thermal zone lock out of the governors (diff)
downloadlinux-dev-a930da9bf583b2add01fb0e086913664dadaffd0.tar.xz
linux-dev-a930da9bf583b2add01fb0e086913664dadaffd0.zip
thermal/core: Move the mutex inside the thermal_zone_device_update() function
All the different calls inside the thermal_zone_device_update() function take the mutex. The previous changes move the mutex out of the different functions, like the throttling ops. Now that the mutexes are all at the same level in the call stack for the thermal_zone_device_update() function, they can be moved inside this one. That has the benefit of: 1. Simplify the code by not having a plethora of places where the lock is taken 2. Probably closes more race windows because releasing the lock from one line to another can give the opportunity to the thermal zone to change its state in the meantime. For example, the thermal zone can be enabled right after checking it is disabled. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20220805153834.2510142-5-daniel.lezcano@linaro.org
Diffstat (limited to 'drivers/thermal/thermal_sysfs.c')
-rw-r--r--drivers/thermal/thermal_sysfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 0f8201060c38..78c5841bdfae 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -49,7 +49,11 @@ static ssize_t
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
- int enabled = thermal_zone_device_is_enabled(tz);
+ int enabled;
+
+ mutex_lock(&tz->lock);
+ enabled = thermal_zone_device_is_enabled(tz);
+ mutex_unlock(&tz->lock);
return sprintf(buf, "%s\n", enabled ? "enabled" : "disabled");
}