diff mbox series

[hwmon-next,1/2] hwmon: (mlxreg-fan) Modify PWM connectivity validation

Message ID 20210926053541.1806937-2-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
Validate PWM connectivity only for additional PWM - "pwm1" is connected
on all systems, while "pwm2" - "pwm4" are optional. Validate
connectivity only for optional attributes by reading of related "pwm{n}"
registers - in case "pwm{n}" is not connected, register value is
supposed to be 0xff.

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

Comments

Guenter Roeck Oct. 8, 2021, 2:15 p.m. UTC | #1
On Sun, Sep 26, 2021 at 08:35:40AM +0300, Vadim Pasternak wrote:
> Validate PWM connectivity only for additional PWM - "pwm1" is connected
> on all systems, while "pwm2" - "pwm4" are optional. Validate
> connectivity only for optional attributes by reading of related "pwm{n}"
> registers - in case "pwm{n}" is not connected, register value is
> supposed to be 0xff.
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/mlxreg-fan.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
> index feab9ec6a6ca..8e5cd6991929 100644
> --- a/drivers/hwmon/mlxreg-fan.c
> +++ b/drivers/hwmon/mlxreg-fan.c
> @@ -488,9 +488,14 @@ static int mlxreg_fan_config(struct mlxreg_fan *fan,
>  				return -EINVAL;
>  			}
>  
> -			err = mlxreg_pwm_connect_verify(fan, data);
> -			if (err)
> -				return err;
> +			/* Validate if more then one PWM is connected. */
> +			if (pwm_num) {
> +				err = mlxreg_pwm_connect_verify(fan, data);
> +				if (err < 0)
> +					return err;
> +				else if (!err)
> +					continue;
> +			}
>  
>  			fan->pwm[pwm_num].reg = data->reg;
>  			fan->pwm[pwm_num].connected = true;
diff mbox series

Patch

diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
index feab9ec6a6ca..8e5cd6991929 100644
--- a/drivers/hwmon/mlxreg-fan.c
+++ b/drivers/hwmon/mlxreg-fan.c
@@ -488,9 +488,14 @@  static int mlxreg_fan_config(struct mlxreg_fan *fan,
 				return -EINVAL;
 			}
 
-			err = mlxreg_pwm_connect_verify(fan, data);
-			if (err)
-				return err;
+			/* Validate if more then one PWM is connected. */
+			if (pwm_num) {
+				err = mlxreg_pwm_connect_verify(fan, data);
+				if (err < 0)
+					return err;
+				else if (!err)
+					continue;
+			}
 
 			fan->pwm[pwm_num].reg = data->reg;
 			fan->pwm[pwm_num].connected = true;