aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorIra W. Snyder <iws@ovro.caltech.edu>2010-05-27 13:59:02 -0400
committerJean Delvare <khali@linux-fr.org>2010-05-27 13:59:02 -0400
commitdf16dd53c575d0cb9dbee20a3149927c862a9ff6 (patch)
tree767244e8aaa1d9bcb996e4fc83637eb100ff7868 /drivers/hwmon
parentea694431f9c862bd409c90ba1cb3bdc6fdde8635 (diff)
hwmon: (ltc4245) Read only one GPIO pin
Read only one of the GPIO pins as an analog voltage. The ADC can be switched to a different GPIO pin at runtime, but this is not supported. Previously, this driver would report the analog voltage of the currently selected GPIO pin as all three GPIO voltages: in9_input, in10_input and in11_input. Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu> Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: stable@kernel.org
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ltc4245.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c
index 65c232a9d0c5..21d201befc2c 100644
--- a/drivers/hwmon/ltc4245.c
+++ b/drivers/hwmon/ltc4245.c
@@ -45,9 +45,7 @@ enum ltc4245_cmd {
45 LTC4245_VEEIN = 0x19, 45 LTC4245_VEEIN = 0x19,
46 LTC4245_VEESENSE = 0x1a, 46 LTC4245_VEESENSE = 0x1a,
47 LTC4245_VEEOUT = 0x1b, 47 LTC4245_VEEOUT = 0x1b,
48 LTC4245_GPIOADC1 = 0x1c, 48 LTC4245_GPIOADC = 0x1c,
49 LTC4245_GPIOADC2 = 0x1d,
50 LTC4245_GPIOADC3 = 0x1e,
51}; 49};
52 50
53struct ltc4245_data { 51struct ltc4245_data {
@@ -61,7 +59,7 @@ struct ltc4245_data {
61 u8 cregs[0x08]; 59 u8 cregs[0x08];
62 60
63 /* Voltage registers */ 61 /* Voltage registers */
64 u8 vregs[0x0f]; 62 u8 vregs[0x0d];
65}; 63};
66 64
67static struct ltc4245_data *ltc4245_update_device(struct device *dev) 65static struct ltc4245_data *ltc4245_update_device(struct device *dev)
@@ -86,7 +84,7 @@ static struct ltc4245_data *ltc4245_update_device(struct device *dev)
86 data->cregs[i] = val; 84 data->cregs[i] = val;
87 } 85 }
88 86
89 /* Read voltage registers -- 0x10 to 0x1f */ 87 /* Read voltage registers -- 0x10 to 0x1c */
90 for (i = 0; i < ARRAY_SIZE(data->vregs); i++) { 88 for (i = 0; i < ARRAY_SIZE(data->vregs); i++) {
91 val = i2c_smbus_read_byte_data(client, i+0x10); 89 val = i2c_smbus_read_byte_data(client, i+0x10);
92 if (unlikely(val < 0)) 90 if (unlikely(val < 0))
@@ -128,9 +126,7 @@ static int ltc4245_get_voltage(struct device *dev, u8 reg)
128 case LTC4245_VEEOUT: 126 case LTC4245_VEEOUT:
129 voltage = regval * -55; 127 voltage = regval * -55;
130 break; 128 break;
131 case LTC4245_GPIOADC1: 129 case LTC4245_GPIOADC:
132 case LTC4245_GPIOADC2:
133 case LTC4245_GPIOADC3:
134 voltage = regval * 10; 130 voltage = regval * 10;
135 break; 131 break;
136 default: 132 default:
@@ -297,9 +293,7 @@ LTC4245_ALARM(in7_min_alarm, (1 << 2), LTC4245_FAULT2);
297LTC4245_ALARM(in8_min_alarm, (1 << 3), LTC4245_FAULT2); 293LTC4245_ALARM(in8_min_alarm, (1 << 3), LTC4245_FAULT2);
298 294
299/* GPIO voltages */ 295/* GPIO voltages */
300LTC4245_VOLTAGE(in9_input, LTC4245_GPIOADC1); 296LTC4245_VOLTAGE(in9_input, LTC4245_GPIOADC);
301LTC4245_VOLTAGE(in10_input, LTC4245_GPIOADC2);
302LTC4245_VOLTAGE(in11_input, LTC4245_GPIOADC3);
303 297
304/* Power Consumption (virtual) */ 298/* Power Consumption (virtual) */
305LTC4245_POWER(power1_input, LTC4245_12VSENSE); 299LTC4245_POWER(power1_input, LTC4245_12VSENSE);
@@ -342,8 +336,6 @@ static struct attribute *ltc4245_attributes[] = {
342 &sensor_dev_attr_in8_min_alarm.dev_attr.attr, 336 &sensor_dev_attr_in8_min_alarm.dev_attr.attr,
343 337
344 &sensor_dev_attr_in9_input.dev_attr.attr, 338 &sensor_dev_attr_in9_input.dev_attr.attr,
345 &sensor_dev_attr_in10_input.dev_attr.attr,
346 &sensor_dev_attr_in11_input.dev_attr.attr,
347 339
348 &sensor_dev_attr_power1_input.dev_attr.attr, 340 &sensor_dev_attr_power1_input.dev_attr.attr,
349 &sensor_dev_attr_power2_input.dev_attr.attr, 341 &sensor_dev_attr_power2_input.dev_attr.attr,