Skip to content

Commit 57f0766

Browse files
committed
thermal: core: Add and use a reverse thermal zone guard
Add a guard for unlocking a locked thermal zone temporarily and use it in thermal_zone_pm_prepare(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Lukasz Luba <[email protected]>
1 parent cba00d1 commit 57f0766

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

drivers/thermal/thermal_core.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,11 +1711,9 @@ static void thermal_zone_pm_prepare(struct thermal_zone_device *tz)
17111711
* acquired the lock yet, so release it to let the function run
17121712
* and wait util it has done the work.
17131713
*/
1714-
mutex_unlock(&tz->lock);
1715-
1716-
wait_for_completion(&tz->resume);
1717-
1718-
mutex_lock(&tz->lock);
1714+
scoped_guard(thermal_zone_reverse, tz) {
1715+
wait_for_completion(&tz->resume);
1716+
}
17191717
}
17201718

17211719
tz->state |= TZ_STATE_FLAG_SUSPENDED;

drivers/thermal/thermal_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ struct thermal_zone_device {
150150
DEFINE_GUARD(thermal_zone, struct thermal_zone_device *, mutex_lock(&_T->lock),
151151
mutex_unlock(&_T->lock))
152152

153+
DEFINE_GUARD(thermal_zone_reverse, struct thermal_zone_device *,
154+
mutex_unlock(&_T->lock), mutex_lock(&_T->lock))
155+
153156
/* Initial thermal zone temperature. */
154157
#define THERMAL_TEMP_INIT INT_MIN
155158

0 commit comments

Comments
 (0)