2023-11-21 08:17:00

by Xing Tong Wu

[permalink] [raw]
Subject: [PATCH v3 2/2] hwmon: (nct6775) Fix fan speed set failure in automatic mode

From: Xing Tong Wu <[email protected]>

Setting the fan speed is only valid in manual mode; it is not possible
to set the fan's speed in automatic mode.
Return error when attempting to set the fan speed in automatic mode.

Signed-off-by: Xing Tong Wu <[email protected]>
---
drivers/hwmon/nct6775-core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 88300fb99bb9..83f1da5acd22 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -2553,6 +2553,13 @@ store_pwm(struct device *dev, struct device_attribute *attr, const char *buf,
int err;
u16 reg;

+ /*
+ * The fan control mode should be set to manual if the user wants to adjust
+ * the fan speed. Otherwise, it will fail to set.
+ */
+ if (index == 0 && data->pwm_enable[nr] > manual)
+ return -EBUSY;
+
err = kstrtoul(buf, 10, &val);
if (err < 0)
return err;
--
2.25.1


2023-11-21 16:00:05

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v3 2/2] hwmon: (nct6775) Fix fan speed set failure in automatic mode

On Tue, Nov 21, 2023 at 04:16:04PM +0800, Xing Tong Wu wrote:
> From: Xing Tong Wu <[email protected]>
>
> Setting the fan speed is only valid in manual mode; it is not possible
> to set the fan's speed in automatic mode.
> Return error when attempting to set the fan speed in automatic mode.
>
> Signed-off-by: Xing Tong Wu <[email protected]>

Applied.

Thanks,
Guenter

> ---
> drivers/hwmon/nct6775-core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
> index 88300fb99bb9..83f1da5acd22 100644
> --- a/drivers/hwmon/nct6775-core.c
> +++ b/drivers/hwmon/nct6775-core.c
> @@ -2553,6 +2553,13 @@ store_pwm(struct device *dev, struct device_attribute *attr, const char *buf,
> int err;
> u16 reg;
>
> + /*
> + * The fan control mode should be set to manual if the user wants to adjust
> + * the fan speed. Otherwise, it will fail to set.
> + */
> + if (index == 0 && data->pwm_enable[nr] > manual)
> + return -EBUSY;
> +
> err = kstrtoul(buf, 10, &val);
> if (err < 0)
> return err;