Commit 158ce075 authored by Jean Delvare's avatar Jean Delvare Committed by Mark M. Hoffman

hwmon/w83627ehf: Preserve speed reading when changing fan min

The w83627ehf driver changes the fan clock divider automatically when
a new min fan speed is set. It is supposed to preserve the fan speed
reading while doing so, bug doesn't really. Fix it.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
parent e432dc81
...@@ -716,10 +716,15 @@ store_fan_min(struct device *dev, struct device_attribute *attr, ...@@ -716,10 +716,15 @@ store_fan_min(struct device *dev, struct device_attribute *attr,
/* Write both the fan clock divider (if it changed) and the new /* Write both the fan clock divider (if it changed) and the new
fan min (unconditionally) */ fan min (unconditionally) */
if (new_div != data->fan_div[nr]) { if (new_div != data->fan_div[nr]) {
if (new_div > data->fan_div[nr]) /* Preserve the fan speed reading */
data->fan[nr] >>= (data->fan_div[nr] - new_div); if (data->fan[nr] != 0xff) {
else if (new_div > data->fan_div[nr])
data->fan[nr] <<= (new_div - data->fan_div[nr]); data->fan[nr] >>= new_div - data->fan_div[nr];
else if (data->fan[nr] & 0x80)
data->fan[nr] = 0xff;
else
data->fan[nr] <<= data->fan_div[nr] - new_div;
}
dev_dbg(dev, "fan%u clock divider changed from %u to %u\n", dev_dbg(dev, "fan%u clock divider changed from %u to %u\n",
nr + 1, div_from_reg(data->fan_div[nr]), nr + 1, div_from_reg(data->fan_div[nr]),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment