Skip to content

Commit af73d53

Browse files
committed
thermal: core: Separate thermal zone governor initialization
In preparation for a subsequent change that will switch over the thermal core to using a mutex guard for managing thermal_governor_lock, move the code running in thermal_zone_device_register_with_trips() under that lock into a separate function called thermal_zone_init_governor(). While at it, drop a useless comment. 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 a5a98a7 commit af73d53

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

drivers/thermal/thermal_core.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,25 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
13451345
}
13461346
EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
13471347

1348+
static int thermal_zone_init_governor(struct thermal_zone_device *tz)
1349+
{
1350+
struct thermal_governor *governor;
1351+
int ret;
1352+
1353+
mutex_lock(&thermal_governor_lock);
1354+
1355+
if (tz->tzp)
1356+
governor = __find_governor(tz->tzp->governor_name);
1357+
else
1358+
governor = def_governor;
1359+
1360+
ret = thermal_set_governor(tz, governor);
1361+
1362+
mutex_unlock(&thermal_governor_lock);
1363+
1364+
return ret;
1365+
}
1366+
13481367
static void thermal_zone_init_complete(struct thermal_zone_device *tz)
13491368
{
13501369
struct thermal_cooling_device *cdev;
@@ -1409,7 +1428,6 @@ thermal_zone_device_register_with_trips(const char *type,
14091428
struct thermal_trip_desc *td;
14101429
int id;
14111430
int result;
1412-
struct thermal_governor *governor;
14131431

14141432
if (!type || strlen(type) == 0) {
14151433
pr_err("No thermal zone type defined\n");
@@ -1507,21 +1525,9 @@ thermal_zone_device_register_with_trips(const char *type,
15071525
if (result)
15081526
goto release_device;
15091527

1510-
/* Update 'this' zone's governor information */
1511-
mutex_lock(&thermal_governor_lock);
1512-
1513-
if (tz->tzp)
1514-
governor = __find_governor(tz->tzp->governor_name);
1515-
else
1516-
governor = def_governor;
1517-
1518-
result = thermal_set_governor(tz, governor);
1519-
if (result) {
1520-
mutex_unlock(&thermal_governor_lock);
1528+
result = thermal_zone_init_governor(tz);
1529+
if (result)
15211530
goto unregister;
1522-
}
1523-
1524-
mutex_unlock(&thermal_governor_lock);
15251531

15261532
if (!tz->tzp || !tz->tzp->no_hwmon) {
15271533
result = thermal_add_hwmon_sysfs(tz);

0 commit comments

Comments
 (0)