提交 33a7ab91 编写于 作者: J Jean Delvare 提交者: Jean Delvare

hwmon: (w83l768ng) Fix fan speed control range

The W83L786NG stores the fan speed on 4 bits while the sysfs interface
uses a 0-255 range. Thus the driver should scale the user input down
to map it to the device range, and scale up the value read from the
device before presenting it to the user. The reserved register nibble
should be left unchanged.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Cc: stable@vger.kernel.org
Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
上级 cf7559bc
...@@ -481,9 +481,11 @@ store_pwm(struct device *dev, struct device_attribute *attr, ...@@ -481,9 +481,11 @@ store_pwm(struct device *dev, struct device_attribute *attr,
if (err) if (err)
return err; return err;
val = clamp_val(val, 0, 255); val = clamp_val(val, 0, 255);
val = DIV_ROUND_CLOSEST(val, 0x11);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->pwm[nr] = val; data->pwm[nr] = val * 0x11;
val |= w83l786ng_read_value(client, W83L786NG_REG_PWM[nr]) & 0xf0;
w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val); w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
...@@ -777,8 +779,9 @@ static struct w83l786ng_data *w83l786ng_update_device(struct device *dev) ...@@ -777,8 +779,9 @@ static struct w83l786ng_data *w83l786ng_update_device(struct device *dev)
? 0 : 1; ? 0 : 1;
data->pwm_enable[i] = data->pwm_enable[i] =
((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3) + 1; ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3) + 1;
data->pwm[i] = w83l786ng_read_value(client, data->pwm[i] =
W83L786NG_REG_PWM[i]); (w83l786ng_read_value(client, W83L786NG_REG_PWM[i])
& 0x0f) * 0x11;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册