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>
This commit is contained in:
Jean Delvare 2008-04-12 19:56:35 +02:00 committed by Mark M. Hoffman
parent dd1ac5384a
commit 7133e56f29
1 changed files with 6 additions and 9 deletions

View File

@ -308,10 +308,8 @@ struct lm85_data {
u8 pwm[3]; /* Register value */ u8 pwm[3]; /* Register value */
u8 temp_ext[3]; /* Decoded values */ u8 temp_ext[3]; /* Decoded values */
u8 in_ext[8]; /* Decoded values */ u8 in_ext[8]; /* Decoded values */
u8 smooth[1]; /* Register encoding */
u8 vid; /* Register value */ u8 vid; /* Register value */
u8 vrm; /* VRM version */ u8 vrm; /* VRM version */
u8 syncpwm3; /* Saved PWM3 for TACH 2,3,4 config */
u32 alarms; /* Register encoding, combined */ u32 alarms; /* Register encoding, combined */
struct lm85_autofan autofan[3]; struct lm85_autofan autofan[3];
struct lm85_zone zone[3]; struct lm85_zone zone[3];
@ -756,14 +754,15 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm85_data *data = i2c_get_clientdata(client); struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10); long val = simple_strtol(buf, NULL, 10);
u8 tmp;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->autofan[nr].min_off = val; data->autofan[nr].min_off = val;
lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1);
| data->syncpwm3 tmp &= ~(0x20 << nr);
| (data->autofan[0].min_off ? 0x20 : 0) if (data->autofan[nr].min_off)
| (data->autofan[1].min_off ? 0x40 : 0) tmp |= 0x20 << nr;
| (data->autofan[2].min_off ? 0x80 : 0)); lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
} }
@ -1531,8 +1530,6 @@ static struct lm85_data *lm85_update_device(struct device *dev)
} }
i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1);
data->smooth[0] = i & 0x0f;
data->syncpwm3 = i & 0x10; /* Save PWM3 config */
data->autofan[0].min_off = (i & 0x20) != 0; data->autofan[0].min_off = (i & 0x20) != 0;
data->autofan[1].min_off = (i & 0x40) != 0; data->autofan[1].min_off = (i & 0x40) != 0;
data->autofan[2].min_off = (i & 0x80) != 0; data->autofan[2].min_off = (i & 0x80) != 0;