diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-04-12 13:56:35 -0400 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2008-07-31 23:44:03 -0400 |
commit | 7133e56f29030b13601d3399e20050053e560860 (patch) | |
tree | 0847f9d75e30b465fb8919793baf874281a2902a /drivers | |
parent | dd1ac5384a08946a99e974bf5749d382e92ed3c0 (diff) |
hwmon: (lm85) Don't write back cached values
In set_pwm_auto_pwm_minctl, we write cached register bits back to the
chip. This is a bad idea as we have no guarantee that the cache is
up-to-date. Better read a fresh register value from the chip, it's
safer and in fact it is also more simple.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Juerg Haefliger <juergh at gmail.com>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/lm85.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 0d31435b333c..645b98c187c2 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -308,10 +308,8 @@ struct lm85_data { | |||
308 | u8 pwm[3]; /* Register value */ | 308 | u8 pwm[3]; /* Register value */ |
309 | u8 temp_ext[3]; /* Decoded values */ | 309 | u8 temp_ext[3]; /* Decoded values */ |
310 | u8 in_ext[8]; /* Decoded values */ | 310 | u8 in_ext[8]; /* Decoded values */ |
311 | u8 smooth[1]; /* Register encoding */ | ||
312 | u8 vid; /* Register value */ | 311 | u8 vid; /* Register value */ |
313 | u8 vrm; /* VRM version */ | 312 | u8 vrm; /* VRM version */ |
314 | u8 syncpwm3; /* Saved PWM3 for TACH 2,3,4 config */ | ||
315 | u32 alarms; /* Register encoding, combined */ | 313 | u32 alarms; /* Register encoding, combined */ |
316 | struct lm85_autofan autofan[3]; | 314 | struct lm85_autofan autofan[3]; |
317 | struct lm85_zone zone[3]; | 315 | struct lm85_zone zone[3]; |
@@ -756,14 +754,15 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, | |||
756 | struct i2c_client *client = to_i2c_client(dev); | 754 | struct i2c_client *client = to_i2c_client(dev); |
757 | struct lm85_data *data = i2c_get_clientdata(client); | 755 | struct lm85_data *data = i2c_get_clientdata(client); |
758 | long val = simple_strtol(buf, NULL, 10); | 756 | long val = simple_strtol(buf, NULL, 10); |
757 | u8 tmp; | ||
759 | 758 | ||
760 | mutex_lock(&data->update_lock); | 759 | mutex_lock(&data->update_lock); |
761 | data->autofan[nr].min_off = val; | 760 | data->autofan[nr].min_off = val; |
762 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] | 761 | tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
763 | | data->syncpwm3 | 762 | tmp &= ~(0x20 << nr); |
764 | | (data->autofan[0].min_off ? 0x20 : 0) | 763 | if (data->autofan[nr].min_off) |
765 | | (data->autofan[1].min_off ? 0x40 : 0) | 764 | tmp |= 0x20 << nr; |
766 | | (data->autofan[2].min_off ? 0x80 : 0)); | 765 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp); |
767 | mutex_unlock(&data->update_lock); | 766 | mutex_unlock(&data->update_lock); |
768 | return count; | 767 | return count; |
769 | } | 768 | } |
@@ -1531,8 +1530,6 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1531 | } | 1530 | } |
1532 | 1531 | ||
1533 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); | 1532 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
1534 | data->smooth[0] = i & 0x0f; | ||
1535 | data->syncpwm3 = i & 0x10; /* Save PWM3 config */ | ||
1536 | data->autofan[0].min_off = (i & 0x20) != 0; | 1533 | data->autofan[0].min_off = (i & 0x20) != 0; |
1537 | data->autofan[1].min_off = (i & 0x40) != 0; | 1534 | data->autofan[1].min_off = (i & 0x40) != 0; |
1538 | data->autofan[2].min_off = (i & 0x80) != 0; | 1535 | data->autofan[2].min_off = (i & 0x80) != 0; |