]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
thermal: core: Add and use a reverse thermal zone guard
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 10 Oct 2024 22:07:11 +0000 (00:07 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 23 Oct 2024 09:56:27 +0000 (11:56 +0200)
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 <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/3344086.aeNJFYEL58@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h

index d1038d33f17e4747386e2db05f923fc7b0a160cc..b8cd84a8c86cf0dab440d360186ec24b9bdee243 100644 (file)
@@ -1711,11 +1711,9 @@ static void thermal_zone_pm_prepare(struct thermal_zone_device *tz)
                 * acquired the lock yet, so release it to let the function run
                 * and wait util it has done the work.
                 */
-               mutex_unlock(&tz->lock);
-
-               wait_for_completion(&tz->resume);
-
-               mutex_lock(&tz->lock);
+               scoped_guard(thermal_zone_reverse, tz) {
+                       wait_for_completion(&tz->resume);
+               }
        }
 
        tz->state |= TZ_STATE_FLAG_SUSPENDED;
index 09f796fb1278d0435c06fb7c3a34dd8dd8403a5c..dc84862017ea5dd6e9cd73aa8953e0e19c40aba4 100644 (file)
@@ -150,6 +150,9 @@ struct thermal_zone_device {
 DEFINE_GUARD(thermal_zone, struct thermal_zone_device *, mutex_lock(&_T->lock),
             mutex_unlock(&_T->lock))
 
+DEFINE_GUARD(thermal_zone_reverse, struct thermal_zone_device *,
+            mutex_unlock(&_T->lock), mutex_lock(&_T->lock))
+
 /* Initial thermal zone temperature. */
 #define THERMAL_TEMP_INIT      INT_MIN