diff options
| author | Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> | 2026-04-29 18:14:14 +0200 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@kernel.org> | 2026-05-26 13:24:29 +0200 |
| commit | 31da1d4451c88b63779bc3f855ae15f718c0e539 (patch) | |
| tree | d18e038943f69638c3d6692773fc2fdd3788c3e3 /drivers/thermal | |
| parent | ee126267bc04bfb03816ae9d71ca24c5bf99e739 (diff) | |
thermal/core: Use devm_add_action_or_reset() when registering a cooling device
Use devm_add_action_or_reset() which does the replaced code. It
results in a simpler and more concise code.
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Link: https://patch.msgid.link/20260429161430.3802970-2-daniel.lezcano@oss.qualcomm.com
Diffstat (limited to 'drivers/thermal')
| -rw-r--r-- | drivers/thermal/thermal_core.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 7d7ce855ae88..db01361569d7 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1140,10 +1140,11 @@ thermal_of_cooling_device_register(struct device_node *np, } EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register); -static void thermal_cooling_device_release(struct device *dev, void *res) +static void thermal_cooling_device_release(void *data) { - thermal_cooling_device_unregister( - *(struct thermal_cooling_device **)res); + struct thermal_cooling_device *cdev = data; + + thermal_cooling_device_unregister(cdev); } /** @@ -1169,23 +1170,18 @@ devm_thermal_of_cooling_device_register(struct device *dev, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { - struct thermal_cooling_device **ptr, *tcd; - - ptr = devres_alloc(thermal_cooling_device_release, sizeof(*ptr), - GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); + struct thermal_cooling_device *cdev; + int ret; - tcd = __thermal_cooling_device_register(np, type, devdata, ops); - if (IS_ERR(tcd)) { - devres_free(ptr); - return tcd; - } + cdev = __thermal_cooling_device_register(np, type, devdata, ops); + if (IS_ERR(cdev)) + return cdev; - *ptr = tcd; - devres_add(dev, ptr); + ret = devm_add_action_or_reset(dev, thermal_cooling_device_release, cdev); + if (ret) + return ERR_PTR(ret); - return tcd; + return cdev; } EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register); |
