From: Daniel Lezcano Date: Fri, 8 May 2026 18:05:11 +0000 (+0200) Subject: thermal/core: Use the thermal class pointer as init guard X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=499274d078d0c9299af671bcaaecbd9c90571539;p=thirdparty%2Flinux.git thermal/core: Use the thermal class pointer as init guard The thermal class is now dynamically allocated and stored as a pointer. Use the thermal_class pointer itself to check whether the thermal class has been created instead of keeping a separate thermal_class_unavailable flag. Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba Link: https://patch.msgid.link/20260508180511.1306659-5-daniel.lezcano@oss.qualcomm.com Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 06d8640819d2b..ca3b6bf2f2927 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -890,7 +890,6 @@ unbind: } static struct class *thermal_class __ro_after_init; -static bool thermal_class_unavailable __ro_after_init = true; static inline void print_bind_err_msg(struct thermal_zone_device *tz, @@ -993,7 +992,7 @@ __thermal_cooling_device_register(struct device_node *np, !ops->set_cur_state) return ERR_PTR(-EINVAL); - if (thermal_class_unavailable) + if (!thermal_class) return ERR_PTR(-ENODEV); cdev = kzalloc_obj(*cdev); @@ -1476,7 +1475,7 @@ thermal_zone_device_register_with_trips(const char *type, if (polling_delay && passive_delay > polling_delay) return ERR_PTR(-EINVAL); - if (thermal_class_unavailable) + if (!thermal_class) return ERR_PTR(-ENODEV); tz = kzalloc_flex(*tz, trips, num_trips); @@ -1774,7 +1773,7 @@ static void __thermal_pm_prepare(void) void thermal_pm_prepare(void) { - if (thermal_class_unavailable) + if (!thermal_class) return; __thermal_pm_prepare(); @@ -1805,7 +1804,7 @@ void thermal_pm_complete(void) { struct thermal_zone_device *tz; - if (thermal_class_unavailable) + if (!thermal_class) return; guard(mutex)(&thermal_list_lock); @@ -1844,8 +1843,6 @@ static int __init thermal_init(void) } thermal_class = tc; - thermal_class_unavailable = false; - return 0; unregister_governors: