hwmon: (nct6775) Fix fan speed set failure in automatic mode

[ Upstream commit 8b3800256a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Xing Tong Wu 2023-11-21 16:16:04 +08:00 committed by Greg Kroah-Hartman
parent bf808f5868
commit fb55c3cee6
1 changed files with 7 additions and 0 deletions

View File

@ -2462,6 +2462,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;