aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-05 16:17:25 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-15 12:06:33 -0400
commitd8f74643578fd5b0c35a944c32e02379e1b22838 (patch)
tree6e5baf39d42709d5e359da5dee973e1dfeea7d19 /drivers
parent3db891afe349069162cf7d6fe92e12c7f75ad893 (diff)
hwmon: (tmp421) Restore missing inputs
commit 8d59582a867470a3e0c3eced4a01625ae8dc546b upstream. An off-by-one error caused some inputs to not be created by the driver when they should. TMP421 gets only one input instead of two, TMP422 gets two instead of three, etc. Fix the bug by listing explicitly the number of inputs each device has. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Andre Prendel <andre.prendel@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/tmp421.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
index 65095feadc0f..bb9760d7e8b6 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 };
61#define TMP423_DEVICE_ID 0x23 61#define TMP423_DEVICE_ID 0x23
62 62
63static const struct i2c_device_id tmp421_id[] = { 63static const struct i2c_device_id tmp421_id[] = {
64 { "tmp421", tmp421 }, 64 { "tmp421", 2 },
65 { "tmp422", tmp422 }, 65 { "tmp422", 3 },
66 { "tmp423", tmp423 }, 66 { "tmp423", 4 },
67 { } 67 { }
68}; 68};
69MODULE_DEVICE_TABLE(i2c, tmp421_id); 69MODULE_DEVICE_TABLE(i2c, tmp421_id);
@@ -73,7 +73,7 @@ struct tmp421_data {
73 struct mutex update_lock; 73 struct mutex update_lock;
74 char valid; 74 char valid;
75 unsigned long last_updated; 75 unsigned long last_updated;
76 int kind; 76 int channels;
77 u8 config; 77 u8 config;
78 s16 temp[4]; 78 s16 temp[4];
79}; 79};
@@ -109,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev)
109 data->config = i2c_smbus_read_byte_data(client, 109 data->config = i2c_smbus_read_byte_data(client,
110 TMP421_CONFIG_REG_1); 110 TMP421_CONFIG_REG_1);
111 111
112 for (i = 0; i <= data->kind; i++) { 112 for (i = 0; i < data->channels; i++) {
113 data->temp[i] = i2c_smbus_read_byte_data(client, 113 data->temp[i] = i2c_smbus_read_byte_data(client,
114 TMP421_TEMP_MSB[i]) << 8; 114 TMP421_TEMP_MSB[i]) << 8;
115 data->temp[i] |= i2c_smbus_read_byte_data(client, 115 data->temp[i] |= i2c_smbus_read_byte_data(client,
@@ -168,7 +168,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a,
168 devattr = container_of(a, struct device_attribute, attr); 168 devattr = container_of(a, struct device_attribute, attr);
169 index = to_sensor_dev_attr(devattr)->index; 169 index = to_sensor_dev_attr(devattr)->index;
170 170
171 if (data->kind > index) 171 if (index < data->channels)
172 return a->mode; 172 return a->mode;
173 173
174 return 0; 174 return 0;
@@ -273,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client,
273 273
274 i2c_set_clientdata(client, data); 274 i2c_set_clientdata(client, data);
275 mutex_init(&data->update_lock); 275 mutex_init(&data->update_lock);
276 data->kind = id->driver_data; 276 data->channels = id->driver_data;
277 277
278 err = tmp421_init_client(client); 278 err = tmp421_init_client(client);
279 if (err) 279 if (err)