diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-02-25 11:19:42 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-15 01:36:25 -0400 |
commit | de24880586b28f1dc4cf91f5db962f0083baab2a (patch) | |
tree | 670f2c12cf071e8376bb57f3f56af75880e37dc8 /drivers/hwmon/lm85.c | |
parent | 502b5a0199209001b34b623132ea313790acbd5d (diff) |
hwmon: (lm85) Use boolean to determine if VID5 is configured
ADT7463 and ADT7468 optionally support VID5 instead of the standard +12V
measurement input. Use a boolean to identify the chip configuration instead of
hardcoding it several times.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r-- | drivers/hwmon/lm85.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index d2cc28660816..22536761a7fd 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -306,6 +306,8 @@ struct lm85_data { | |||
306 | const int *freq_map; | 306 | const int *freq_map; |
307 | enum chips type; | 307 | enum chips type; |
308 | 308 | ||
309 | bool has_vid5; /* true if VID5 is configured for ADT7463 or ADT7468 */ | ||
310 | |||
309 | struct mutex update_lock; | 311 | struct mutex update_lock; |
310 | int valid; /* !=0 if following fields are valid */ | 312 | int valid; /* !=0 if following fields are valid */ |
311 | unsigned long last_reading; /* In jiffies */ | 313 | unsigned long last_reading; /* In jiffies */ |
@@ -420,8 +422,7 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, | |||
420 | struct lm85_data *data = lm85_update_device(dev); | 422 | struct lm85_data *data = lm85_update_device(dev); |
421 | int vid; | 423 | int vid; |
422 | 424 | ||
423 | if ((data->type == adt7463 || data->type == adt7468) && | 425 | if (data->has_vid5) { |
424 | (data->vid & 0x80)) { | ||
425 | /* 6-pin VID (VRM 10) */ | 426 | /* 6-pin VID (VRM 10) */ |
426 | vid = vid_from_reg(data->vid & 0x3f, data->vrm); | 427 | vid = vid_from_reg(data->vid & 0x3f, data->vrm); |
427 | } else { | 428 | } else { |
@@ -1321,9 +1322,13 @@ static int lm85_probe(struct i2c_client *client, | |||
1321 | 1322 | ||
1322 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used | 1323 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used |
1323 | as a sixth digital VID input rather than an analog input. */ | 1324 | as a sixth digital VID input rather than an analog input. */ |
1324 | data->vid = lm85_read_value(client, LM85_REG_VID); | 1325 | if (data->type == adt7463 || data->type == adt7468) { |
1325 | if (!((data->type == adt7463 || data->type == adt7468) && | 1326 | u8 vid = lm85_read_value(client, LM85_REG_VID); |
1326 | (data->vid & 0x80))) | 1327 | if (vid & 0x80) |
1328 | data->has_vid5 = true; | ||
1329 | } | ||
1330 | |||
1331 | if (!data->has_vid5) | ||
1327 | if ((err = sysfs_create_group(&client->dev.kobj, | 1332 | if ((err = sysfs_create_group(&client->dev.kobj, |
1328 | &lm85_group_in4))) | 1333 | &lm85_group_in4))) |
1329 | goto err_remove_files; | 1334 | goto err_remove_files; |
@@ -1457,11 +1462,8 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1457 | lm85_read_value(client, LM85_REG_FAN(i)); | 1462 | lm85_read_value(client, LM85_REG_FAN(i)); |
1458 | } | 1463 | } |
1459 | 1464 | ||
1460 | if (!((data->type == adt7463 || data->type == adt7468) && | 1465 | if (!data->has_vid5) |
1461 | (data->vid & 0x80))) { | 1466 | data->in[4] = lm85_read_value(client, LM85_REG_IN(4)); |
1462 | data->in[4] = lm85_read_value(client, | ||
1463 | LM85_REG_IN(4)); | ||
1464 | } | ||
1465 | 1467 | ||
1466 | if (data->type == adt7468) | 1468 | if (data->type == adt7468) |
1467 | data->cfg5 = lm85_read_value(client, ADT7468_REG_CFG5); | 1469 | data->cfg5 = lm85_read_value(client, ADT7468_REG_CFG5); |
@@ -1528,8 +1530,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1528 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); | 1530 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); |
1529 | } | 1531 | } |
1530 | 1532 | ||
1531 | if (!((data->type == adt7463 || data->type == adt7468) && | 1533 | if (!data->has_vid5) { |
1532 | (data->vid & 0x80))) { | ||
1533 | data->in_min[4] = lm85_read_value(client, | 1534 | data->in_min[4] = lm85_read_value(client, |
1534 | LM85_REG_IN_MIN(4)); | 1535 | LM85_REG_IN_MIN(4)); |
1535 | data->in_max[4] = lm85_read_value(client, | 1536 | data->in_max[4] = lm85_read_value(client, |