]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
thermal: core: Separate thermal zone governor initialization
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 10 Oct 2024 22:20:56 +0000 (00:20 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 24 Oct 2024 12:48:42 +0000 (14:48 +0200)
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 <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/4408795.ejJDZkT8p0@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
drivers/thermal/thermal_core.c

index f98aa396787af59adde03c7aba8ab5ac00bdb93f..6464be98df5f0ad08f7461434bff1f16ea0d1b7a 100644 (file)
@@ -1345,6 +1345,25 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
 }
 EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
 
+static int thermal_zone_init_governor(struct thermal_zone_device *tz)
+{
+       struct thermal_governor *governor;
+       int ret;
+
+       mutex_lock(&thermal_governor_lock);
+
+       if (tz->tzp)
+               governor = __find_governor(tz->tzp->governor_name);
+       else
+               governor = def_governor;
+
+       ret = thermal_set_governor(tz, governor);
+
+       mutex_unlock(&thermal_governor_lock);
+
+       return ret;
+}
+
 static void thermal_zone_init_complete(struct thermal_zone_device *tz)
 {
        struct thermal_cooling_device *cdev;
@@ -1409,7 +1428,6 @@ thermal_zone_device_register_with_trips(const char *type,
        struct thermal_trip_desc *td;
        int id;
        int result;
-       struct thermal_governor *governor;
 
        if (!type || strlen(type) == 0) {
                pr_err("No thermal zone type defined\n");
@@ -1507,21 +1525,9 @@ thermal_zone_device_register_with_trips(const char *type,
        if (result)
                goto release_device;
 
-       /* Update 'this' zone's governor information */
-       mutex_lock(&thermal_governor_lock);
-
-       if (tz->tzp)
-               governor = __find_governor(tz->tzp->governor_name);
-       else
-               governor = def_governor;
-
-       result = thermal_set_governor(tz, governor);
-       if (result) {
-               mutex_unlock(&thermal_governor_lock);
+       result = thermal_zone_init_governor(tz);
+       if (result)
                goto unregister;
-       }
-
-       mutex_unlock(&thermal_governor_lock);
 
        if (!tz->tzp || !tz->tzp->no_hwmon) {
                result = thermal_add_hwmon_sysfs(tz);