diff mbox series

[for,6.13,v1,4/8] thermal: core: Initialize thermal zones before registerimg them

Message ID 10527854.nUPlyArG6x@rjwysocki.net
State Superseded
Headers show
Series thermal: core: Updates related to thermal instances, trip points handling and locking | expand

Commit Message

Rafael J. Wysocki Sept. 10, 2024, 9:31 a.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -1469,6 +1469,7 @@  thermal_zone_device_register_with_trips(
 		thermal_zone_destroy_device_groups(tz);
 		goto remove_id;
 	}
+	thermal_zone_device_init(tz);
 	result = device_register(&tz->device);
 	if (result)
 		goto release_device;
@@ -1507,7 +1508,6 @@  thermal_zone_device_register_with_trips(
 
 	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);