mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 08:15:07 -04:00
thermal/core: Allocate the thermal class dynamically
Use class_create() instead of a statically allocated struct class. This allows the thermal class to be managed through a dynamically allocated class object and avoids keeping a static class instance around. Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> [ rjw: Added __ro_after_init to thermal_class ] [ rjw: Used temporary local var to store class_create() return value ] Link: https://patch.msgid.link/20260508180511.1306659-4-daniel.lezcano@oss.qualcomm.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
dc04e81fa2
commit
34f5400364
@@ -889,9 +889,7 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
|
|||||||
kfree(pos);
|
kfree(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct class thermal_class = {
|
static struct class *thermal_class __ro_after_init;
|
||||||
.name = "thermal",
|
|
||||||
};
|
|
||||||
static bool thermal_class_unavailable __ro_after_init = true;
|
static bool thermal_class_unavailable __ro_after_init = true;
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
@@ -1018,7 +1016,7 @@ __thermal_cooling_device_register(struct device_node *np,
|
|||||||
cdev->np = np;
|
cdev->np = np;
|
||||||
cdev->ops = ops;
|
cdev->ops = ops;
|
||||||
cdev->updated = false;
|
cdev->updated = false;
|
||||||
cdev->device.class = &thermal_class;
|
cdev->device.class = thermal_class;
|
||||||
cdev->device.release = thermal_cdev_release;
|
cdev->device.release = thermal_cdev_release;
|
||||||
cdev->devdata = devdata;
|
cdev->devdata = devdata;
|
||||||
|
|
||||||
@@ -1514,7 +1512,7 @@ thermal_zone_device_register_with_trips(const char *type,
|
|||||||
if (!tz->ops.critical)
|
if (!tz->ops.critical)
|
||||||
tz->ops.critical = thermal_zone_device_critical;
|
tz->ops.critical = thermal_zone_device_critical;
|
||||||
|
|
||||||
tz->device.class = &thermal_class;
|
tz->device.class = thermal_class;
|
||||||
tz->device.release = thermal_zone_device_release;
|
tz->device.release = thermal_zone_device_release;
|
||||||
tz->devdata = devdata;
|
tz->devdata = devdata;
|
||||||
tz->num_trips = num_trips;
|
tz->num_trips = num_trips;
|
||||||
@@ -1820,6 +1818,7 @@ void thermal_pm_complete(void)
|
|||||||
|
|
||||||
static int __init thermal_init(void)
|
static int __init thermal_init(void)
|
||||||
{
|
{
|
||||||
|
struct class *tc;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
thermal_debug_init();
|
thermal_debug_init();
|
||||||
@@ -1838,10 +1837,13 @@ static int __init thermal_init(void)
|
|||||||
if (result)
|
if (result)
|
||||||
goto unregister_governors;
|
goto unregister_governors;
|
||||||
|
|
||||||
result = class_register(&thermal_class);
|
tc = class_create("thermal");
|
||||||
if (result)
|
if (IS_ERR(tc)) {
|
||||||
|
result = PTR_ERR(tc);
|
||||||
goto unregister_governors;
|
goto unregister_governors;
|
||||||
|
}
|
||||||
|
|
||||||
|
thermal_class = tc;
|
||||||
thermal_class_unavailable = false;
|
thermal_class_unavailable = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user