From: Lukasz Luba <lukasz.luba@arm.com>
To: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, rafael@kernel.org
Subject: Re: [PATCH 1/4] thermal/core: Add dedicated release callback for cooling devices
Date: Wed, 13 May 2026 16:02:37 +0100 [thread overview]
Message-ID: <0ecfc773-2df3-4433-a5cb-cf9f18e5b7e6@arm.com> (raw)
In-Reply-To: <20260508180511.1306659-2-daniel.lezcano@oss.qualcomm.com>
Hi Daniel
On 5/8/26 19:05, Daniel Lezcano wrote:
> The thermal class release callback currently handles both thermal
> zones and cooling devices by checking the device name prefix.
>
> Move the cooling device cleanup to a dedicated struct device release
> callback. This avoids relying on device names to select the release
> path and keeps the cooling device lifetime handling local to the
> cooling device object.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
> ---
> drivers/thermal/thermal_core.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 2f4e2dc46b8f..cf5d4a9c11fe 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -952,7 +952,6 @@ static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz,
> static void thermal_release(struct device *dev)
> {
> struct thermal_zone_device *tz;
> - struct thermal_cooling_device *cdev;
>
> if (!strncmp(dev_name(dev), "thermal_zone",
> sizeof("thermal_zone") - 1)) {
> @@ -962,13 +961,6 @@ static void thermal_release(struct device *dev)
> ida_destroy(&tz->ida);
> mutex_destroy(&tz->lock);
> complete(&tz->removal);
> - } else if (!strncmp(dev_name(dev), "cooling_device",
> - sizeof("cooling_device") - 1)) {
> - cdev = to_cooling_device(dev);
> - thermal_cooling_device_destroy_sysfs(cdev);
> - kfree_const(cdev->type);
> - ida_free(&thermal_cdev_ida, cdev->id);
> - kfree(cdev);
> }
> }
>
> @@ -1040,6 +1032,16 @@ static void thermal_cooling_device_init_complete(struct thermal_cooling_device *
> thermal_zone_cdev_bind(tz, cdev);
> }
>
> +static void thermal_cdev_release(struct device *dev)
> +{
> + struct thermal_cooling_device *cdev = to_cooling_device(dev);
> +
> + thermal_cooling_device_destroy_sysfs(cdev);
> + kfree_const(cdev->type);
> + ida_free(&thermal_cdev_ida, cdev->id);
> + kfree(cdev);
> +}
> +
> /**
> * __thermal_cooling_device_register() - register a new thermal cooling device
> * @np: a pointer to a device tree node.
> @@ -1093,6 +1095,7 @@ __thermal_cooling_device_register(struct device_node *np,
> cdev->ops = ops;
> cdev->updated = false;
> cdev->device.class = &thermal_class;
> + cdev->device.release = thermal_cdev_release;
> cdev->devdata = devdata;
>
> ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
I hope it's not too late to the party...
This looks good, we avoid the problem we discussed earlier.
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
The whole patch set makes the things more clean.
It should be a good foundation for your next changes.
Thanks Daniel!
Regards,
Lukasz
next prev parent reply other threads:[~2026-05-13 15:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 18:05 [PATCH 0/4] thermal/core: Decouple release paths for tz and cdev Daniel Lezcano
2026-05-08 18:05 ` [PATCH 1/4] thermal/core: Add dedicated release callback for cooling devices Daniel Lezcano
2026-05-13 15:02 ` Lukasz Luba [this message]
2026-05-08 18:05 ` [PATCH 2/4] thermal/core: Add dedicated release callback for thermal zones Daniel Lezcano
2026-05-13 15:02 ` Lukasz Luba
2026-05-08 18:05 ` [PATCH 3/4] thermal/core: Allocate the thermal class dynamically Daniel Lezcano
2026-05-08 18:24 ` Rafael J. Wysocki
2026-05-08 19:22 ` Daniel Lezcano
2026-05-08 19:26 ` Rafael J. Wysocki
2026-05-08 19:28 ` Daniel Lezcano
2026-05-13 15:03 ` Lukasz Luba
2026-05-08 18:05 ` [PATCH 4/4] thermal/core: Use the thermal class pointer as init guard Daniel Lezcano
2026-05-13 15:03 ` Lukasz Luba
2026-05-08 18:10 ` [PATCH 0/4] thermal/core: Decouple release paths for tz and cdev Daniel Lezcano
2026-05-13 14:22 ` Daniel Lezcano
2026-05-13 15:06 ` Rafael J. Wysocki
2026-05-13 15:45 ` Lukasz Luba
2026-05-13 15:48 ` Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ecfc773-2df3-4433-a5cb-cf9f18e5b7e6@arm.com \
--to=lukasz.luba@arm.com \
--cc=daniel.lezcano@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox