]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal/core: Use the thermal class pointer as init guard
authorDaniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Fri, 8 May 2026 18:05:11 +0000 (20:05 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 13 May 2026 19:03:38 +0000 (21:03 +0200)
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 <daniel.lezcano@oss.qualcomm.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260508180511.1306659-5-daniel.lezcano@oss.qualcomm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c

index 06d8640819d2ba2115454e732d056ed339d19f8d..ca3b6bf2f292779eb5ba35ab1e37584ce11f2738 100644 (file)
@@ -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: