@@ -202,16 +202,13 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
202202 int ret = - EINVAL ;
203203
204204 mutex_lock (& thermal_governor_lock );
205- mutex_lock (& tz -> lock );
206205
207- gov = __find_governor (strim (policy ));
208- if (!gov )
209- goto exit ;
206+ guard (thermal_zone )(tz );
210207
211- ret = thermal_set_governor (tz , gov );
208+ gov = __find_governor (strim (policy ));
209+ if (gov )
210+ ret = thermal_set_governor (tz , gov );
212211
213- exit :
214- mutex_unlock (& tz -> lock );
215212 mutex_unlock (& thermal_governor_lock );
216213
217214 thermal_notify_tz_gov_change (tz , policy );
@@ -617,26 +614,18 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
617614{
618615 int ret ;
619616
620- mutex_lock ( & tz -> lock );
617+ guard ( thermal_zone )( tz );
621618
622619 /* do nothing if mode isn't changing */
623- if (mode == tz -> mode ) {
624- mutex_unlock (& tz -> lock );
625-
620+ if (mode == tz -> mode )
626621 return 0 ;
627- }
628622
629623 ret = __thermal_zone_device_set_mode (tz , mode );
630- if (ret ) {
631- mutex_unlock (& tz -> lock );
632-
624+ if (ret )
633625 return ret ;
634- }
635626
636627 __thermal_zone_device_update (tz , THERMAL_EVENT_UNSPECIFIED );
637628
638- mutex_unlock (& tz -> lock );
639-
640629 if (mode == THERMAL_DEVICE_ENABLED )
641630 thermal_notify_tz_enable (tz );
642631 else
@@ -665,10 +654,10 @@ static bool thermal_zone_is_present(struct thermal_zone_device *tz)
665654void thermal_zone_device_update (struct thermal_zone_device * tz ,
666655 enum thermal_notify_event event )
667656{
668- mutex_lock (& tz -> lock );
657+ guard (thermal_zone )(tz );
658+
669659 if (thermal_zone_is_present (tz ))
670660 __thermal_zone_device_update (tz , event );
671- mutex_unlock (& tz -> lock );
672661}
673662EXPORT_SYMBOL_GPL (thermal_zone_device_update );
674663
@@ -972,12 +961,10 @@ static bool __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
972961static void thermal_zone_cdev_bind (struct thermal_zone_device * tz ,
973962 struct thermal_cooling_device * cdev )
974963{
975- mutex_lock ( & tz -> lock );
964+ guard ( thermal_zone )( tz );
976965
977966 if (__thermal_zone_cdev_bind (tz , cdev ))
978967 __thermal_zone_device_update (tz , THERMAL_EVENT_UNSPECIFIED );
979-
980- mutex_unlock (& tz -> lock );
981968}
982969
983970/**
@@ -1284,11 +1271,9 @@ static void __thermal_zone_cdev_unbind(struct thermal_zone_device *tz,
12841271static void thermal_zone_cdev_unbind (struct thermal_zone_device * tz ,
12851272 struct thermal_cooling_device * cdev )
12861273{
1287- mutex_lock ( & tz -> lock );
1274+ guard ( thermal_zone )( tz );
12881275
12891276 __thermal_zone_cdev_unbind (tz , cdev );
1290-
1291- mutex_unlock (& tz -> lock );
12921277}
12931278
12941279/**
@@ -1334,7 +1319,7 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
13341319 if (tz -> ops .get_crit_temp )
13351320 return tz -> ops .get_crit_temp (tz , temp );
13361321
1337- mutex_lock ( & tz -> lock );
1322+ guard ( thermal_zone )( tz );
13381323
13391324 for_each_trip_desc (tz , td ) {
13401325 const struct thermal_trip * trip = & td -> trip ;
@@ -1346,8 +1331,6 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
13461331 }
13471332 }
13481333
1349- mutex_unlock (& tz -> lock );
1350-
13511334 return ret ;
13521335}
13531336EXPORT_SYMBOL_GPL (thermal_zone_get_crit_temp );
@@ -1360,7 +1343,7 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz)
13601343
13611344 list_add_tail (& tz -> node , & thermal_tz_list );
13621345
1363- mutex_lock ( & tz -> lock );
1346+ guard ( thermal_zone )( tz );
13641347
13651348 /* Bind cooling devices for this zone. */
13661349 list_for_each_entry (cdev , & thermal_cdev_list , node )
@@ -1377,8 +1360,6 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz)
13771360
13781361 __thermal_zone_device_update (tz , THERMAL_EVENT_UNSPECIFIED );
13791362
1380- mutex_unlock (& tz -> lock );
1381-
13821363 mutex_unlock (& thermal_list_lock );
13831364}
13841365
@@ -1615,7 +1596,7 @@ static bool thermal_zone_exit(struct thermal_zone_device *tz)
16151596 goto unlock ;
16161597 }
16171598
1618- mutex_lock ( & tz -> lock );
1599+ guard ( thermal_zone )( tz );
16191600
16201601 tz -> state |= TZ_STATE_FLAG_EXIT ;
16211602 list_del_init (& tz -> node );
@@ -1624,8 +1605,6 @@ static bool thermal_zone_exit(struct thermal_zone_device *tz)
16241605 list_for_each_entry (cdev , & thermal_cdev_list , node )
16251606 __thermal_zone_cdev_unbind (tz , cdev );
16261607
1627- mutex_unlock (& tz -> lock );
1628-
16291608unlock :
16301609 mutex_unlock (& thermal_list_lock );
16311610
@@ -1710,7 +1689,7 @@ static void thermal_zone_device_resume(struct work_struct *work)
17101689
17111690 tz = container_of (work , struct thermal_zone_device , poll_queue .work );
17121691
1713- mutex_lock ( & tz -> lock );
1692+ guard ( thermal_zone )( tz );
17141693
17151694 tz -> state &= ~(TZ_STATE_FLAG_SUSPENDED | TZ_STATE_FLAG_RESUMING );
17161695
@@ -1720,13 +1699,11 @@ static void thermal_zone_device_resume(struct work_struct *work)
17201699 __thermal_zone_device_update (tz , THERMAL_TZ_RESUME );
17211700
17221701 complete (& tz -> resume );
1723-
1724- mutex_unlock (& tz -> lock );
17251702}
17261703
17271704static void thermal_zone_pm_prepare (struct thermal_zone_device * tz )
17281705{
1729- mutex_lock ( & tz -> lock );
1706+ guard ( thermal_zone )( tz );
17301707
17311708 if (tz -> state & TZ_STATE_FLAG_RESUMING ) {
17321709 /*
@@ -1742,13 +1719,11 @@ static void thermal_zone_pm_prepare(struct thermal_zone_device *tz)
17421719 }
17431720
17441721 tz -> state |= TZ_STATE_FLAG_SUSPENDED ;
1745-
1746- mutex_unlock (& tz -> lock );
17471722}
17481723
17491724static void thermal_zone_pm_complete (struct thermal_zone_device * tz )
17501725{
1751- mutex_lock ( & tz -> lock );
1726+ guard ( thermal_zone )( tz );
17521727
17531728 cancel_delayed_work (& tz -> poll_queue );
17541729
@@ -1762,8 +1737,6 @@ static void thermal_zone_pm_complete(struct thermal_zone_device *tz)
17621737 INIT_DELAYED_WORK (& tz -> poll_queue , thermal_zone_device_resume );
17631738 /* Queue up the work without a delay. */
17641739 mod_delayed_work (system_freezable_power_efficient_wq , & tz -> poll_queue , 0 );
1765-
1766- mutex_unlock (& tz -> lock );
17671740}
17681741
17691742static int thermal_pm_notify (struct notifier_block * nb ,
0 commit comments