]> git.ipfire.org Git - thirdparty/linux.git/commit
thermal/core: Split __thermal_cooling_device_register() into two functions
authorDaniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Tue, 5 May 2026 14:44:47 +0000 (16:44 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 15 May 2026 20:31:16 +0000 (22:31 +0200)
commit13f4e660a1268dbc9c3fcba7fe214868c7c45062
tree50ec77c49644ffe8fac097c9c0bffd8711222ca4
parentcfb5dc0f60fbe95a10cb307cc6dae5c47f160abb
thermal/core: Split __thermal_cooling_device_register() into two functions

In preparation for the upcoming changes separating OF and non-OF code,
split __thermal_cooling_device_register() into allocation and addition
phases.

This allows moving the device node assignment out of the core
initialization path.

This change is not a trivial split. The lifetime of the cooling device
is managed by the device core through put_device(), which triggers
thermal_release() to free all associated resources.

With the introduction of thermal_cooling_device_alloc(), the allocation
path must mirror what thermal_release() undoes. In contrast,
thermal_cooling_device_add() must not perform any rollback and relies
on put_device() for cleanup on error paths. This avoids both double
free and resource leaks.

As part of this rework, add the missing device_initialize() call when
allocating the cooling device.

Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
[ rjw: Replace device_register() with device_add() ]
[ rjw: Rebase on top of previously applied material ]
Link: https://patch.msgid.link/20260505144447.2853933-1-daniel.lezcano@oss.qualcomm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c