From: Rafael J. Wysocki Date: Wed, 22 Apr 2026 15:37:14 +0000 (+0200) Subject: thermal: core: Remove dead code from two functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c5281c91e1f6c719ee6db9e18ef5efb618425e7;p=thirdparty%2Flinux.git thermal: core: Remove dead code from two functions 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 Link: https://patch.msgid.link/3950489.kQq0lBPeGt@rafael.j.wysocki --- diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 2f4e2dc46b8f7..23d460a5da585 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -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,