[PATCH 1/2] hwmon: emc2305: Update cooling device registration to include device node

florin.leotescu@oss.nxp.com posted 2 patches 12 months ago
There is a newer version of this series
[PATCH 1/2] hwmon: emc2305: Update cooling device registration to include device node
Posted by florin.leotescu@oss.nxp.com 12 months ago
From: Florin Leotescu <florin.leotescu@nxp.com>

This patch updates the EMC2305 hwmon driver to register the thermal
cooling device with Device Tree (DTS) node. This change allows
cooling device to be configured based on the properties defined
in the Device Tree.

Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com>
---
 drivers/hwmon/emc2305.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index 4d39fbd83769..18e765902d32 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -293,8 +293,9 @@ static int emc2305_set_single_tz(struct device *dev, int idx)
 	pwm = data->pwm_min[cdev_idx];
 
 	data->cdev_data[cdev_idx].cdev =
-		thermal_cooling_device_register(emc2305_fan_name[idx], data,
-						&emc2305_cooling_ops);
+		devm_thermal_of_cooling_device_register(dev, dev->of_node,
+							emc2305_fan_name[idx], data,
+							&emc2305_cooling_ops);
 
 	if (IS_ERR(data->cdev_data[cdev_idx].cdev)) {
 		dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]);
-- 
2.34.1
Re: [PATCH 1/2] hwmon: emc2305: Update cooling device registration to include device node
Posted by Guenter Roeck 12 months ago
On 2/9/25 23:31, florin.leotescu@oss.nxp.com wrote:
> From: Florin Leotescu <florin.leotescu@nxp.com>
> 
> This patch updates the EMC2305 hwmon driver to register the thermal
> cooling device with Device Tree (DTS) node. This change allows
> cooling device to be configured based on the properties defined
> in the Device Tree.
> 
> Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com>
> ---
>   drivers/hwmon/emc2305.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
> index 4d39fbd83769..18e765902d32 100644
> --- a/drivers/hwmon/emc2305.c
> +++ b/drivers/hwmon/emc2305.c
> @@ -293,8 +293,9 @@ static int emc2305_set_single_tz(struct device *dev, int idx)
>   	pwm = data->pwm_min[cdev_idx];
>   
>   	data->cdev_data[cdev_idx].cdev =
> -		thermal_cooling_device_register(emc2305_fan_name[idx], data,
> -						&emc2305_cooling_ops);
> +		devm_thermal_of_cooling_device_register(dev, dev->of_node,
> +							emc2305_fan_name[idx], data,
> +							&emc2305_cooling_ops);


The use of a devm_ function means that

         for (i = 0; i < EMC2305_PWM_MAX; i++)
                 if (data->cdev_data[i].cdev)
                         thermal_cooling_device_unregister(data->cdev_data[i].cdev);

and thus each call to emc2305_unset_tz() will be fatal after this change.
I don't mind the change itself, but emc2305_unset_tz() and all calls to it
will have to be removed as well.

Guenter