]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: core: Initialize thermal zones before registering them
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 4 Oct 2024 19:05:49 +0000 (21:05 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 22 Oct 2024 10:06:06 +0000 (12:06 +0200)
Since user space can start interacting with a new thermal zone as soon
as device_register() called by thermal_zone_device_register_with_trips()
returns, it is better to initialize the thermal zone before calling
device_register() on it.

Fixes: d0df264fbd3c ("thermal/core: Remove pointless thermal_zone_device_reset() function")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/3336146.44csPzL39Z@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
drivers/thermal/thermal_core.c

index 1e87256e86bef4ecbdffd0a12cc14301c82088af..03f5ac996a7aff054a51c9009baa62fa3e42c3b9 100644 (file)
@@ -1467,6 +1467,7 @@ thermal_zone_device_register_with_trips(const char *type,
                thermal_zone_destroy_device_groups(tz);
                goto remove_id;
        }
+       thermal_zone_device_init(tz);
        result = device_register(&tz->device);
        if (result)
                goto release_device;
@@ -1509,7 +1510,6 @@ thermal_zone_device_register_with_trips(const char *type,
 
        mutex_unlock(&thermal_list_lock);
 
-       thermal_zone_device_init(tz);
        /* Update the new thermal zone and mark it as already updated. */
        if (atomic_cmpxchg(&tz->need_update, 1, 0))
                thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);