Re: [PATCH] thermal/of: Move OF code where it belongs to
From: Rafael J. Wysocki
Date: Wed Apr 08 2026 - 06:36:30 EST
On Tue, Apr 7, 2026 at 7:10 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>
> On Tue, Apr 7, 2026 at 5:51 PM Daniel Lezcano <daniel.lezcano@xxxxxxxxxx> wrote:
> >
> > From: Daniel Lezcano <daniel.lezcano@xxxxxxxxxxxxxxxx>
> >
> > The functions:
> > - thermal_of_cooling_device_register()
> > - devm_thermal_of_cooling_device_register()
> >
> > are related to thermal-of but they are implemented in
> > thermal-core. Move these functions to the right file.
> >
> > Pure move patch.
> >
> > No functional change intended.
> >
> > Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
> > ---
> > drivers/thermal/thermal_core.c | 75 +---------------------------------
> > drivers/thermal/thermal_core.h | 5 +++
> > drivers/thermal/thermal_of.c | 72 ++++++++++++++++++++++++++++++++
> > 3 files changed, 78 insertions(+), 74 deletions(-)
> >
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index b7d706ed7ed9..f0049cff1128 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -1054,7 +1054,7 @@ static void thermal_cooling_device_init_complete(struct thermal_cooling_device *
> > * Return: a pointer to the created struct thermal_cooling_device or an
> > * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> > */
> > -static struct thermal_cooling_device *
> > +struct thermal_cooling_device *
> > __thermal_cooling_device_register(struct device_node *np,
> > const char *type, void *devdata,
> > const struct thermal_cooling_device_ops *ops)
> > @@ -1162,79 +1162,6 @@ thermal_cooling_device_register(const char *type, void *devdata,
> > }
> > EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
> >
> > -/**
> > - * thermal_of_cooling_device_register() - register an OF thermal cooling device
> > - * @np: a pointer to a device tree node.
> > - * @type: the thermal cooling device type.
> > - * @devdata: device private data.
> > - * @ops: standard thermal cooling devices callbacks.
> > - *
> > - * This function will register a cooling device with device tree node reference.
> > - * 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.
> > - *
> > - * Return: a pointer to the created struct thermal_cooling_device or an
> > - * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> > - */
> > -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np,
> > - const char *type, void *devdata,
> > - const struct thermal_cooling_device_ops *ops)
> > -{
> > - return __thermal_cooling_device_register(np, type, devdata, ops);
> > -}
> > -EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
> > -
> > -static void thermal_cooling_device_release(struct device *dev, void *res)
> > -{
> > - thermal_cooling_device_unregister(
> > - *(struct thermal_cooling_device **)res);
> > -}
> > -
> > -/**
> > - * devm_thermal_of_cooling_device_register() - register an OF thermal cooling
> > - * device
> > - * @dev: a valid struct device pointer of a sensor device.
> > - * @np: a pointer to a device tree node.
> > - * @type: the thermal cooling device type.
> > - * @devdata: device private data.
> > - * @ops: standard thermal cooling devices callbacks.
> > - *
> > - * This function will register a cooling device with device tree node reference.
> > - * 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.
> > - *
> > - * Return: a pointer to the created struct thermal_cooling_device or an
> > - * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> > - */
> > -struct thermal_cooling_device *
> > -devm_thermal_of_cooling_device_register(struct device *dev,
> > - struct device_node *np,
> > - 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);
> > -
> > - tcd = __thermal_cooling_device_register(np, type, devdata, ops);
> > - if (IS_ERR(tcd)) {
> > - devres_free(ptr);
> > - return tcd;
> > - }
> > -
> > - *ptr = tcd;
> > - devres_add(dev, ptr);
> > -
> > - return tcd;
> > -}
> > -EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
> > -
> > static bool thermal_cooling_device_present(struct thermal_cooling_device *cdev)
> > {
> > struct thermal_cooling_device *pos = NULL;
> > diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> > index d3acff602f9c..bdd59947b24f 100644
> > --- a/drivers/thermal/thermal_core.h
> > +++ b/drivers/thermal/thermal_core.h
> > @@ -269,6 +269,11 @@ void thermal_zone_device_critical_shutdown(struct thermal_zone_device *tz);
> > void thermal_governor_update_tz(struct thermal_zone_device *tz,
> > enum thermal_notify_event reason);
> >
> > +struct thermal_cooling_device *
> > +__thermal_cooling_device_register(struct device_node *np,
> > + const char *type, void *devdata,
> > + const struct thermal_cooling_device_ops *ops);
> > +
> > /* Helpers */
> > #define for_each_trip_desc(__tz, __td) \
> > for (__td = __tz->trips; __td - __tz->trips < __tz->num_trips; __td++)
> > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> > index 99085c806a1f..398157e740fc 100644
> > --- a/drivers/thermal/thermal_of.c
> > +++ b/drivers/thermal/thermal_of.c
> > @@ -510,3 +510,75 @@ void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_dev
> > devm_thermal_of_zone_match, tz));
> > }
> > EXPORT_SYMBOL_GPL(devm_thermal_of_zone_unregister);
> > +
> > +/**
> > + * thermal_of_cooling_device_register() - register an OF thermal cooling device
> > + * @np: a pointer to a device tree node.
> > + * @type: the thermal cooling device type.
> > + * @devdata: device private data.
> > + * @ops: standard thermal cooling devices callbacks.
> > + *
> > + * This function will register a cooling device with device tree node reference.
> > + * 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.
> > + *
> > + * Return: a pointer to the created struct thermal_cooling_device or an
> > + * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> > + */
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > + const char *type, void *devdata,
> > + const struct thermal_cooling_device_ops *ops)
> > +{
> > + return __thermal_cooling_device_register(np, type, devdata, ops);
> > +}
> > +EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
> > +
> > +static void thermal_cooling_device_release(struct device *dev, void *res)
> > +{
> > + thermal_cooling_device_unregister(*(struct thermal_cooling_device **)res);
> > +}
> > +
> > +/**
> > + * devm_thermal_of_cooling_device_register() - register an OF thermal cooling
> > + * device
> > + * @dev: a valid struct device pointer of a sensor device.
> > + * @np: a pointer to a device tree node.
> > + * @type: the thermal cooling device type.
> > + * @devdata: device private data.
> > + * @ops: standard thermal cooling devices callbacks.
> > + *
> > + * This function will register a cooling device with device tree node reference.
> > + * 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.
> > + *
> > + * Return: a pointer to the created struct thermal_cooling_device or an
> > + * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
> > + */
> > +struct thermal_cooling_device *
> > +devm_thermal_of_cooling_device_register(struct device *dev,
> > + struct device_node *np,
> > + 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);
> > +
> > + tcd = __thermal_cooling_device_register(np, type, devdata, ops);
> > + if (IS_ERR(tcd)) {
> > + devres_free(ptr);
> > + return tcd;
> > + }
> > +
> > + *ptr = tcd;
> > + devres_add(dev, ptr);
> > +
> > + return tcd;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
> > --
>
> Applied as 7.1 material, thanks!
And dropped because of a build issue introduced by it:
https://lore.kernel.org/linux-pm/202604081734.3OJSeExW-lkp@xxxxxxxxx/