hwmon: (nct6775) Fix fan speed set failure in automatic mode
authorXing Tong Wu <xingtong.wu@siemens.com>
Tue, 21 Nov 2023 08:16:04 +0000 (16:16 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 11 Dec 2023 14:21:00 +0000 (06:21 -0800)
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 <xingtong.wu@siemens.com>
Link: https://lore.kernel.org/r/20231121081604.2499-3-xingtong_wu@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/nct6775-core.c

index 49f8e4a7beaf5c5201c5c924de6a0f97ebbd6f6e..8d2ef3145bca3c71b0aee2d8a1fb466dd3f9cb3e 100644 (file)
@@ -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;