aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-10-17 11:51:09 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-10-17 11:51:09 -0400
commit5f502a834a6471dc3cc456ccef66292e9e3a152e (patch)
treee5302049c34bfc5c526d7d666929b04b0a4a2149 /drivers/hwmon
parentf65e17086fc141bee1592bbf6e709e9c7a43541b (diff)
hwmon: (lm90) Don't access nonexistent registers on Maxim chips
The Maxim chips supported by the lm90 driver have 8-bit high and low remote limit values, not 11-bit as the other chips have. So stop reading from and writing to registers that do not exist on these chips. Also round the limit values set by the user properly. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Martyn Welch <martyn.welch@gefanuc.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm90.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 16b99e0bdff0..90489b8f5c8b 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -323,12 +323,16 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
323 mutex_lock(&data->update_lock); 323 mutex_lock(&data->update_lock);
324 if (data->kind == adt7461) 324 if (data->kind == adt7461)
325 data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); 325 data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);
326 else if (data->kind == max6657 || data->kind == max6680)
327 data->temp11[nr] = TEMP1_TO_REG(val) << 8;
326 else 328 else
327 data->temp11[nr] = TEMP2_TO_REG(val); 329 data->temp11[nr] = TEMP2_TO_REG(val);
330
328 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 331 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
329 data->temp11[nr] >> 8); 332 data->temp11[nr] >> 8);
330 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 333 if (data->kind != max6657 && data->kind != max6680)
331 data->temp11[nr] & 0xff); 334 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
335 data->temp11[nr] & 0xff);
332 mutex_unlock(&data->update_lock); 336 mutex_unlock(&data->update_lock);
333 return count; 337 return count;
334} 338}
@@ -801,12 +805,21 @@ static struct lm90_data *lm90_update_device(struct device *dev)
801 lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, 805 lm90_read16(client, LM90_REG_R_REMOTE_TEMPH,
802 LM90_REG_R_REMOTE_TEMPL, &data->temp11[0]); 806 LM90_REG_R_REMOTE_TEMPL, &data->temp11[0]);
803 807
804 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0 808 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0) {
805 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0) 809 data->temp11[1] = h << 8;
806 data->temp11[1] = (h << 8) | l; 810 if (data->kind != max6657 && data->kind != max6680
807 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0 811 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL,
808 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) 812 &l) == 0)
809 data->temp11[2] = (h << 8) | l; 813 data->temp11[1] |= l;
814 }
815 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0) {
816 data->temp11[2] = h << 8;
817 if (data->kind != max6657 && data->kind != max6680
818 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL,
819 &l) == 0)
820 data->temp11[2] |= l;
821 }
822
810 if (data->kind != max6657) { 823 if (data->kind != max6657) {
811 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH, 824 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH,
812 &h) == 0 825 &h) == 0