From: Armin Wolf <W_Armin@gmx.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Hans de Goede <hansg@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [PATCH v1 03/10] thermal: core: Introduce thermal_cooling_device_create()
Date: Fri, 11 Sep 2026 23:04:50 +0200 [thread overview]
Message-ID: <7ef819c3-5155-48fb-828a-48d9bd72e54b@gmx.de> (raw)
In-Reply-To: <8729484.T7Z3S40VBb@rafael.j.wysocki>
Am 11.09.26 um 15:02 schrieb Rafael J. Wysocki:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Currently, thermal cooling devices have no parents, but it would be
> generally useful to be able to create them under specific parents in
> the device hierarchy (for instance, it may help to identify the device
> representing the actual cooling hardware).
>
> To make that possible, add thermal_cooling_device_create() that will
> work like thermal_cooling_device_register() except that it will take
> an additional parent argument (which may be NULL).
>
> Redefine thermal_cooling_device_register() as a static inline wrapper
> around thermal_cooling_device_create().
Hi,
i like your idea with the new registration function, this gives us more time
for migrating the other drivers. Should we mark the original function as
deprecated?
For the patch itself:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/thermal/thermal_core.c | 28 ++++++++++++++++------------
> drivers/thermal/thermal_core.h | 3 ++-
> drivers/thermal/thermal_of.c | 2 +-
> include/linux/thermal.h | 19 ++++++++++++++-----
> 4 files changed, 33 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 82e2f0d8a26d..ac928c199829 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1005,7 +1005,8 @@ thermal_cooling_device_alloc(const char *type, const struct thermal_cooling_devi
> return ERR_PTR(ret);
> }
>
> -int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void *devdata)
> +int thermal_cooling_device_add(struct thermal_cooling_device *cdev,
> + struct device *parent, void *devdata)
> {
> unsigned long current_state;
> int ret;
> @@ -1013,6 +1014,7 @@ int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void *devdat
> mutex_init(&cdev->lock);
> INIT_LIST_HEAD(&cdev->thermal_instances);
> cdev->updated = false;
> + cdev->device.parent = parent;
> cdev->device.class = &thermal_class;
> cdev->device.release = thermal_cdev_release;
> device_initialize(&cdev->device);
> @@ -1062,21 +1064,23 @@ int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void *devdat
> }
>
> /**
> - * thermal_cooling_device_register() - register a new thermal cooling device
> + * thermal_cooling_device_create() - register a new thermal cooling device
> + * @parent: parent device (optional).
> * @type: the thermal cooling device type.
> * @devdata: device private data.
> * @ops: standard thermal cooling devices callbacks.
> *
> - * This interface function adds a new thermal cooling device (fan/processor/...)
> - * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
> - * to all the thermal zone devices registered at the same time.
> + * Allocate and register a new thermal cooling device under the given parent (if
> + * not NULL) and with the given type, device data, and operations. During the
> + * registration, it will be matched against all of the registered thermal zones
> + * and it will be bound to the matching ones.
> *
> - * Return: a pointer to the created struct thermal_cooling_device or an
> - * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> + * Return: A pointer to the created struct thermal_cooling_device or an ERR_PTR.
> + * Callers must use IS_ERR*() helpers to check the return value.
> */
> -struct thermal_cooling_device *
> -thermal_cooling_device_register(const char *type, void *devdata,
> - const struct thermal_cooling_device_ops *ops)
> +struct thermal_cooling_device *thermal_cooling_device_create(
> + struct device *parent, const char *type, void *devdata,
> + const struct thermal_cooling_device_ops *ops)
> {
> struct thermal_cooling_device *cdev;
> int ret;
> @@ -1085,13 +1089,13 @@ thermal_cooling_device_register(const char *type, void *devdata,
> if (IS_ERR(cdev))
> return cdev;
>
> - ret = thermal_cooling_device_add(cdev, devdata);
> + ret = thermal_cooling_device_add(cdev, parent, devdata);
> if (ret)
> return ERR_PTR(ret);
>
> return cdev;
> }
> -EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
> +EXPORT_SYMBOL_GPL(thermal_cooling_device_create);
>
> static void thermal_cooling_device_release(void *data)
> {
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index e98b0aa5aacc..7ef7c6cab437 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -270,7 +270,8 @@ void thermal_governor_update_tz(struct thermal_zone_device *tz,
> struct thermal_cooling_device *
> thermal_cooling_device_alloc(const char *type, const struct thermal_cooling_device_ops *ops);
>
> -int thermal_cooling_device_add(struct thermal_cooling_device *cdev, void *devdata);
> +int thermal_cooling_device_add(struct thermal_cooling_device *cdev,
> + struct device *parent, void *devdata);
>
> /* Helpers */
> #define for_each_trip_desc(__tz, __td) \
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 0217a49b08ae..14dfac9359b8 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -561,7 +561,7 @@ thermal_of_cooling_device_register(struct device_node *np, u32 cdev_id,
> cdev->np = np;
> cdev->cdev_id = cdev_id;
>
> - ret = thermal_cooling_device_add(cdev, devdata);
> + ret = thermal_cooling_device_add(cdev, NULL, devdata);
> if (ret)
> return ERR_PTR(ret);
>
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 083b4f533933..306ad17aed89 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -293,8 +293,9 @@ struct device *thermal_zone_device(struct thermal_zone_device *tzd);
> void thermal_zone_device_update(struct thermal_zone_device *,
> enum thermal_notify_event);
>
> -struct thermal_cooling_device *thermal_cooling_device_register(const char *,
> - void *, const struct thermal_cooling_device_ops *);
> +struct thermal_cooling_device *thermal_cooling_device_create(
> + struct device *parent, const char *type, void *devdata,
> + const struct thermal_cooling_device_ops *ops);
>
> struct thermal_cooling_device *
> devm_thermal_cooling_device_register(struct device *dev, const char *type, void *devdata,
> @@ -340,9 +341,9 @@ static inline void thermal_zone_device_update(struct thermal_zone_device *tz,
> enum thermal_notify_event event)
> { }
>
> -static inline struct thermal_cooling_device *
> -thermal_cooling_device_register(const char *type, void *devdata,
> - const struct thermal_cooling_device_ops *ops)
> +static inline struct thermal_cooling_device *thermal_cooling_device_create(
> + struct device *parent, const char *type, void *devdata,
> + const struct thermal_cooling_device_ops *ops)
> { return ERR_PTR(-ENODEV); }
>
> static inline struct thermal_cooling_device *
> @@ -391,4 +392,12 @@ static inline void thermal_pm_prepare(void) {}
> static inline void thermal_pm_complete(void) {}
> #endif /* CONFIG_THERMAL */
>
> +static inline struct thermal_cooling_device *thermal_cooling_device_register(
> + const char *type, void *devdata,
> + const struct thermal_cooling_device_ops *ops)
> +{
> + return thermal_cooling_device_create(NULL, type, devdata, ops);
> +}
> +
> +
> #endif /* __THERMAL_H__ */
next prev parent reply other threads:[~2026-09-11 21:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 13:00 [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Rafael J. Wysocki
2026-09-11 13:00 ` [PATCH v1 01/10] ACPI: fan: Fix memory leak due to leftover devm_kcalloc() argument Rafael J. Wysocki
2026-09-11 16:29 ` Andy Shevchenko
2026-09-12 13:48 ` Rafael J. Wysocki (Intel)
2026-09-11 21:01 ` Armin Wolf
2026-09-11 13:01 ` [PATCH v1 02/10] ACPI: video: Fix backlight unregistration ordering Rafael J. Wysocki
2026-09-11 16:27 ` Andy Shevchenko
2026-09-11 16:35 ` Rafael J. Wysocki (Intel)
2026-09-11 21:02 ` Armin Wolf
2026-09-11 13:02 ` [PATCH v1 03/10] thermal: core: Introduce thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 21:04 ` Armin Wolf [this message]
2026-09-11 13:02 ` [PATCH v1 04/10] ACPI: processor: thermal: Use thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 16:32 ` Andy Shevchenko
2026-09-11 16:36 ` Rafael J. Wysocki (Intel)
2026-09-11 16:46 ` Andy Shevchenko
2026-09-11 17:01 ` Rafael J. Wysocki (Intel)
2026-09-11 18:06 ` Andy Shevchenko
2026-09-11 21:14 ` Armin Wolf
2026-09-13 8:15 ` Andy Shevchenko
2026-09-13 10:28 ` Rafael J. Wysocki (Intel)
2026-09-11 21:11 ` Armin Wolf
2026-09-11 13:03 ` [PATCH v1 05/10] ACPI: video: " Rafael J. Wysocki
2026-09-11 21:16 ` Armin Wolf
2026-09-11 13:04 ` [PATCH v1 06/10] ACPI: fan: " Rafael J. Wysocki
2026-09-11 21:17 ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 07/10] ACPI: thermal: Use cooling device parent for thermal zone binding Rafael J. Wysocki
2026-09-11 16:36 ` Andy Shevchenko
2026-09-11 16:41 ` Rafael J. Wysocki (Intel)
2026-09-11 21:20 ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 08/10] ACPI: processor: thermal: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:22 ` Armin Wolf
2026-09-11 13:06 ` [PATCH v1 09/10] ACPI: fan: Store ACPI device pointer in struct acpi_fan Rafael J. Wysocki
2026-09-11 21:25 ` Armin Wolf
2026-09-11 13:07 ` [PATCH v1 10/10] ACPI: fan: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:26 ` Armin Wolf
2026-09-11 21:35 ` [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Armin Wolf
2026-09-12 13:34 ` Rafael J. Wysocki (Intel)
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=7ef819c3-5155-48fb-828a-48d9bd72e54b@gmx.de \
--to=w_armin@gmx.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=daniel.lezcano@kernel.org \
--cc=hansg@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
/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