OSDN Git Service

thermal/core: Move the mutex inside the thermal_zone_device_update() function
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 5 Aug 2022 15:38:34 +0000 (17:38 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 17 Aug 2022 12:09:39 +0000 (14:09 +0200)
commita930da9bf583b2add01fb0e086913664dadaffd0
treed4ef64b482bf616f417fffcbbdc60624397cc792
parent670a5e356cb6dfc61b87b599eba483af6a3a99ad
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
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h
drivers/thermal/thermal_helpers.c
drivers/thermal/thermal_sysfs.c