diff mbox series

[hwmon-next,2/2] hwmon: (mlxreg-fan) Support distinctive names per different cooling devices

Message ID 20210926053541.1806937-3-vadimp@nvidia.com (mailing list archive)
State Accepted
Headers show
Series hwmon: (mlxreg-fan) Extend support for multiply PWM | expand

Commit Message

Vadim Pasternak Sept. 26, 2021, 5:35 a.m. UTC
Provide different names for cooling devices registration to allow
binding each cooling devices to relevant thermal zone. Thus, specific
cooling device can be associated with related thermal sensor by setting
thermal cooling device type for example to "mlxreg_fan2" and passing
this type to thermal_zone_bind_cooling_device() through 'cdev->type'.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/hwmon/mlxreg-fan.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Guenter Roeck Oct. 8, 2021, 2:16 p.m. UTC | #1
On Sun, Sep 26, 2021 at 08:35:41AM +0300, Vadim Pasternak wrote:
> Provide different names for cooling devices registration to allow
> binding each cooling devices to relevant thermal zone. Thus, specific
> cooling device can be associated with related thermal sensor by setting
> thermal cooling device type for example to "mlxreg_fan2" and passing
> this type to thermal_zone_bind_cooling_device() through 'cdev->type'.
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/mlxreg-fan.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
> index 8e5cd6991929..4a8becdb0d58 100644
> --- a/drivers/hwmon/mlxreg-fan.c
> +++ b/drivers/hwmon/mlxreg-fan.c
> @@ -263,6 +263,13 @@ mlxreg_fan_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
>  	return 0;
>  }
>  
> +static char *mlxreg_fan_name[] = {
> +	"mlxreg_fan",
> +	"mlxreg_fan1",
> +	"mlxreg_fan2",
> +	"mlxreg_fan3",
> +};
> +
>  static const struct hwmon_channel_info *mlxreg_fan_hwmon_info[] = {
>  	HWMON_CHANNEL_INFO(fan,
>  			   HWMON_F_INPUT | HWMON_F_FAULT,
> @@ -565,8 +572,8 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
>  		if (!pwm->connected)
>  			continue;
>  		pwm->fan = fan;
> -		pwm->cdev = devm_thermal_of_cooling_device_register(dev, NULL, "mlxreg_fan", pwm,
> -								    &mlxreg_fan_cooling_ops);
> +		pwm->cdev = devm_thermal_of_cooling_device_register(dev, NULL, mlxreg_fan_name[i],
> +								    pwm, &mlxreg_fan_cooling_ops);
>  		if (IS_ERR(pwm->cdev)) {
>  			dev_err(dev, "Failed to register cooling device\n");
>  			return PTR_ERR(pwm->cdev);
diff mbox series

Patch

diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
index 8e5cd6991929..4a8becdb0d58 100644
--- a/drivers/hwmon/mlxreg-fan.c
+++ b/drivers/hwmon/mlxreg-fan.c
@@ -263,6 +263,13 @@  mlxreg_fan_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
 	return 0;
 }
 
+static char *mlxreg_fan_name[] = {
+	"mlxreg_fan",
+	"mlxreg_fan1",
+	"mlxreg_fan2",
+	"mlxreg_fan3",
+};
+
 static const struct hwmon_channel_info *mlxreg_fan_hwmon_info[] = {
 	HWMON_CHANNEL_INFO(fan,
 			   HWMON_F_INPUT | HWMON_F_FAULT,
@@ -565,8 +572,8 @@  static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
 		if (!pwm->connected)
 			continue;
 		pwm->fan = fan;
-		pwm->cdev = devm_thermal_of_cooling_device_register(dev, NULL, "mlxreg_fan", pwm,
-								    &mlxreg_fan_cooling_ops);
+		pwm->cdev = devm_thermal_of_cooling_device_register(dev, NULL, mlxreg_fan_name[i],
+								    pwm, &mlxreg_fan_cooling_ops);
 		if (IS_ERR(pwm->cdev)) {
 			dev_err(dev, "Failed to register cooling device\n");
 			return PTR_ERR(pwm->cdev);