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 <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>
This commit is contained in:
Daniel Lezcano 2026-05-08 20:05:11 +02:00 committed by Rafael J. Wysocki
parent 34f5400364
commit 499274d078

View File

@ -890,7 +890,6 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
}
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: