]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: core: Remove dead code from two functions
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 22 Apr 2026 15:37:14 +0000 (17:37 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 May 2026 19:45:46 +0000 (21:45 +0200)
Since thermal_register_governor() is only called by
thermal_register_governors() which runs before clearing
thermal_class_unavailable, thermal_tz_list is guaranteed to be
empty when it runs, so the code walking that list in it is
effectively dead.

The same observation applies to the code walking thermal_tz_list
in thermal_unregister_governor() which is also called only if
thermal_class_unavailable hasn't been cleared.

Remove the dead code from both functions mentioned above and rearrange
thermal_register_governor() to reduce indentation level.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/3950489.kQq0lBPeGt@rafael.j.wysocki
drivers/thermal/thermal_core.c

index 2f4e2dc46b8f718466c88871e0fa815aea4dad75..23d460a5da5854169a46ba36b4cbb13d6c9f55b2 100644 (file)
@@ -118,59 +118,28 @@ static int thermal_set_governor(struct thermal_zone_device *tz,
 
 int thermal_register_governor(struct thermal_governor *governor)
 {
-       int err;
-       const char *name;
-       struct thermal_zone_device *pos;
 
        if (!governor)
                return -EINVAL;
 
        guard(mutex)(&thermal_governor_lock);
 
-       err = -EBUSY;
-       if (!__find_governor(governor->name)) {
-               bool match_default;
+       if (__find_governor(governor->name))
+               return -EBUSY;
 
-               err = 0;
-               list_add(&governor->governor_list, &thermal_governor_list);
-               match_default = !strncmp(governor->name,
-                                        DEFAULT_THERMAL_GOVERNOR,
-                                        THERMAL_NAME_LENGTH);
+       list_add(&governor->governor_list, &thermal_governor_list);
 
-               if (!def_governor && match_default)
-                       def_governor = governor;
-       }
-
-       guard(mutex)(&thermal_list_lock);
-
-       list_for_each_entry(pos, &thermal_tz_list, node) {
-               /*
-                * only thermal zones with specified tz->tzp->governor_name
-                * may run with tz->govenor unset
-                */
-               if (pos->governor)
-                       continue;
-
-               name = pos->tzp->governor_name;
-
-               if (!strncasecmp(name, governor->name, THERMAL_NAME_LENGTH)) {
-                       int ret;
+       if (strncmp(governor->name, DEFAULT_THERMAL_GOVERNOR, THERMAL_NAME_LENGTH))
+               return 0;
 
-                       ret = thermal_set_governor(pos, governor);
-                       if (ret)
-                               dev_err(&pos->device,
-                                       "Failed to set governor %s for thermal zone %s: %d\n",
-                                       governor->name, pos->type, ret);
-               }
-       }
+       if (!def_governor)
+               def_governor = governor;
 
-       return err;
+       return 0;
 }
 
 void thermal_unregister_governor(struct thermal_governor *governor)
 {
-       struct thermal_zone_device *pos;
-
        if (!governor)
                return;
 
@@ -180,14 +149,6 @@ void thermal_unregister_governor(struct thermal_governor *governor)
                return;
 
        list_del(&governor->governor_list);
-
-       guard(mutex)(&thermal_list_lock);
-
-       list_for_each_entry(pos, &thermal_tz_list, node) {
-               if (!strncasecmp(pos->governor->name, governor->name,
-                                THERMAL_NAME_LENGTH))
-                       thermal_set_governor(pos, NULL);
-       }
 }
 
 int thermal_zone_device_set_policy(struct thermal_zone_device *tz,