@@ -124,7 +124,7 @@ int thermal_register_governor(struct thermal_governor *governor)
124
124
if (!governor )
125
125
return - EINVAL ;
126
126
127
- mutex_lock (& thermal_governor_lock );
127
+ guard ( mutex ) (& thermal_governor_lock );
128
128
129
129
err = - EBUSY ;
130
130
if (!__find_governor (governor -> name )) {
@@ -163,8 +163,6 @@ int thermal_register_governor(struct thermal_governor *governor)
163
163
}
164
164
}
165
165
166
- mutex_unlock (& thermal_governor_lock );
167
-
168
166
return err ;
169
167
}
170
168
@@ -175,10 +173,10 @@ void thermal_unregister_governor(struct thermal_governor *governor)
175
173
if (!governor )
176
174
return ;
177
175
178
- mutex_lock (& thermal_governor_lock );
176
+ guard ( mutex ) (& thermal_governor_lock );
179
177
180
178
if (!__find_governor (governor -> name ))
181
- goto exit ;
179
+ return ;
182
180
183
181
list_del (& governor -> governor_list );
184
182
@@ -189,9 +187,6 @@ void thermal_unregister_governor(struct thermal_governor *governor)
189
187
THERMAL_NAME_LENGTH ))
190
188
thermal_set_governor (pos , NULL );
191
189
}
192
-
193
- exit :
194
- mutex_unlock (& thermal_governor_lock );
195
190
}
196
191
197
192
int thermal_zone_device_set_policy (struct thermal_zone_device * tz ,
@@ -200,16 +195,13 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
200
195
struct thermal_governor * gov ;
201
196
int ret = - EINVAL ;
202
197
203
- mutex_lock (& thermal_governor_lock );
204
-
198
+ guard (mutex )(& thermal_governor_lock );
205
199
guard (thermal_zone )(tz );
206
200
207
201
gov = __find_governor (strim (policy ));
208
202
if (gov )
209
203
ret = thermal_set_governor (tz , gov );
210
204
211
- mutex_unlock (& thermal_governor_lock );
212
-
213
205
thermal_notify_tz_gov_change (tz , policy );
214
206
215
207
return ret ;
@@ -220,15 +212,13 @@ int thermal_build_list_of_policies(char *buf)
220
212
struct thermal_governor * pos ;
221
213
ssize_t count = 0 ;
222
214
223
- mutex_lock (& thermal_governor_lock );
215
+ guard ( mutex ) (& thermal_governor_lock );
224
216
225
217
list_for_each_entry (pos , & thermal_governor_list , governor_list ) {
226
218
count += sysfs_emit_at (buf , count , "%s " , pos -> name );
227
219
}
228
220
count += sysfs_emit_at (buf , count , "\n" );
229
221
230
- mutex_unlock (& thermal_governor_lock );
231
-
232
222
return count ;
233
223
}
234
224
@@ -670,17 +660,18 @@ int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
670
660
void * data )
671
661
{
672
662
struct thermal_governor * gov ;
673
- int ret = 0 ;
674
663
675
- mutex_lock (& thermal_governor_lock );
664
+ guard (mutex )(& thermal_governor_lock );
665
+
676
666
list_for_each_entry (gov , & thermal_governor_list , governor_list ) {
667
+ int ret ;
668
+
677
669
ret = cb (gov , data );
678
670
if (ret )
679
- break ;
671
+ return ret ;
680
672
}
681
- mutex_unlock (& thermal_governor_lock );
682
673
683
- return ret ;
674
+ return 0 ;
684
675
}
685
676
686
677
int for_each_thermal_cooling_device (int (* cb )(struct thermal_cooling_device * ,
@@ -1348,20 +1339,15 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
1348
1339
static int thermal_zone_init_governor (struct thermal_zone_device * tz )
1349
1340
{
1350
1341
struct thermal_governor * governor ;
1351
- int ret ;
1352
1342
1353
- mutex_lock (& thermal_governor_lock );
1343
+ guard ( mutex ) (& thermal_governor_lock );
1354
1344
1355
1345
if (tz -> tzp )
1356
1346
governor = __find_governor (tz -> tzp -> governor_name );
1357
1347
else
1358
1348
governor = def_governor ;
1359
1349
1360
- ret = thermal_set_governor (tz , governor );
1361
-
1362
- mutex_unlock (& thermal_governor_lock );
1363
-
1364
- return ret ;
1350
+ return thermal_set_governor (tz , governor );
1365
1351
}
1366
1352
1367
1353
static void thermal_zone_init_complete (struct thermal_zone_device * tz )
0 commit comments