aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 98b53b119c2a..960df9fa75af 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -41,7 +41,8 @@
41 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 41 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
42 * Note that there is no easy way to differentiate between the three 42 * Note that there is no easy way to differentiate between the three
43 * variants. The extra address and features of the MAX6659 are not 43 * variants. The extra address and features of the MAX6659 are not
44 * supported by this driver. 44 * supported by this driver. These chips lack the remote temperature
45 * offset feature.
45 * 46 *
46 * This driver also supports the MAX6680 and MAX6681, two other sensor 47 * This driver also supports the MAX6680 and MAX6681, two other sensor
47 * chips made by Maxim. These are quite similar to the other Maxim 48 * chips made by Maxim. These are quite similar to the other Maxim
@@ -226,9 +227,10 @@ struct lm90_data {
226 2: local high limit 227 2: local high limit
227 3: local critical limit 228 3: local critical limit
228 4: remote critical limit */ 229 4: remote critical limit */
229 s16 temp11[3]; /* 0: remote input 230 s16 temp11[4]; /* 0: remote input
230 1: remote low limit 231 1: remote low limit
231 2: remote high limit */ 232 2: remote high limit
233 3: remote offset (except max6657) */
232 u8 temp_hyst; 234 u8 temp_hyst;
233 u8 alarms; /* bitvector */ 235 u8 alarms; /* bitvector */
234}; 236};
@@ -282,11 +284,13 @@ static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
282static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, 284static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
283 const char *buf, size_t count) 285 const char *buf, size_t count)
284{ 286{
285 static const u8 reg[4] = { 287 static const u8 reg[6] = {
286 LM90_REG_W_REMOTE_LOWH, 288 LM90_REG_W_REMOTE_LOWH,
287 LM90_REG_W_REMOTE_LOWL, 289 LM90_REG_W_REMOTE_LOWL,
288 LM90_REG_W_REMOTE_HIGHH, 290 LM90_REG_W_REMOTE_HIGHH,
289 LM90_REG_W_REMOTE_HIGHL, 291 LM90_REG_W_REMOTE_HIGHL,
292 LM90_REG_W_REMOTE_OFFSH,
293 LM90_REG_W_REMOTE_OFFSL,
290 }; 294 };
291 295
292 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 296 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -367,6 +371,8 @@ static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8,
367static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, 371static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,
368 set_temphyst, 3); 372 set_temphyst, 3);
369static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); 373static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4);
374static SENSOR_DEVICE_ATTR(temp2_offset, S_IWUSR | S_IRUGO, show_temp11,
375 set_temp11, 3);
370 376
371/* Individual alarm files */ 377/* Individual alarm files */
372static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); 378static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0);
@@ -652,6 +658,11 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
652 &dev_attr_pec))) 658 &dev_attr_pec)))
653 goto exit_remove_files; 659 goto exit_remove_files;
654 } 660 }
661 if (data->kind != max6657) {
662 if ((err = device_create_file(&new_client->dev,
663 &sensor_dev_attr_temp2_offset.dev_attr)))
664 goto exit_remove_files;
665 }
655 666
656 data->hwmon_dev = hwmon_device_register(&new_client->dev); 667 data->hwmon_dev = hwmon_device_register(&new_client->dev);
657 if (IS_ERR(data->hwmon_dev)) { 668 if (IS_ERR(data->hwmon_dev)) {
@@ -710,6 +721,9 @@ static int lm90_detach_client(struct i2c_client *client)
710 hwmon_device_unregister(data->hwmon_dev); 721 hwmon_device_unregister(data->hwmon_dev);
711 sysfs_remove_group(&client->dev.kobj, &lm90_group); 722 sysfs_remove_group(&client->dev.kobj, &lm90_group);
712 device_remove_file(&client->dev, &dev_attr_pec); 723 device_remove_file(&client->dev, &dev_attr_pec);
724 if (data->kind != max6657)
725 device_remove_file(&client->dev,
726 &sensor_dev_attr_temp2_offset.dev_attr);
713 727
714 if ((err = i2c_detach_client(client))) 728 if ((err = i2c_detach_client(client)))
715 return err; 729 return err;
@@ -763,6 +777,13 @@ static struct lm90_data *lm90_update_device(struct device *dev)
763 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0 777 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0
764 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) 778 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0)
765 data->temp11[2] = (newh << 8) | l; 779 data->temp11[2] = (newh << 8) | l;
780 if (data->kind != max6657) {
781 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH,
782 &newh) == 0
783 && lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSL,
784 &l) == 0)
785 data->temp11[3] = (newh << 8) | l;
786 }
766 lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); 787 lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms);
767 788
768 data->last_updated = jiffies; 789 data->last_updated = jiffies;