diff options
Diffstat (limited to 'drivers/hwmon/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 37cfc101da5e..558d83b25b68 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -542,18 +542,26 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
542 | return -EINVAL; | 542 | return -EINVAL; |
543 | 543 | ||
544 | mutex_lock(&data->update_lock); | 544 | mutex_lock(&data->update_lock); |
545 | /* Get fresh readings */ | ||
546 | data->fan_div[nr] = adm1031_read_value(client, | ||
547 | ADM1031_REG_FAN_DIV(nr)); | ||
548 | data->fan_min[nr] = adm1031_read_value(client, | ||
549 | ADM1031_REG_FAN_MIN(nr)); | ||
550 | |||
551 | /* Write the new clock divider and fan min */ | ||
545 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); | 552 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); |
546 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); | 553 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); |
547 | new_min = data->fan_min[nr] * old_div / | 554 | new_min = data->fan_min[nr] * old_div / |
548 | FAN_DIV_FROM_REG(data->fan_div[nr]); | 555 | FAN_DIV_FROM_REG(data->fan_div[nr]); |
549 | data->fan_min[nr] = new_min > 0xff ? 0xff : new_min; | 556 | data->fan_min[nr] = new_min > 0xff ? 0xff : new_min; |
550 | data->fan[nr] = data->fan[nr] * old_div / | ||
551 | FAN_DIV_FROM_REG(data->fan_div[nr]); | ||
552 | 557 | ||
553 | adm1031_write_value(client, ADM1031_REG_FAN_DIV(nr), | 558 | adm1031_write_value(client, ADM1031_REG_FAN_DIV(nr), |
554 | data->fan_div[nr]); | 559 | data->fan_div[nr]); |
555 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), | 560 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), |
556 | data->fan_min[nr]); | 561 | data->fan_min[nr]); |
562 | |||
563 | /* Invalidate the cache: fan speed is no longer valid */ | ||
564 | data->valid = 0; | ||
557 | mutex_unlock(&data->update_lock); | 565 | mutex_unlock(&data->update_lock); |
558 | return count; | 566 | return count; |
559 | } | 567 | } |