aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-05 16:17:25 -0500
committerJean Delvare <khali@linux-fr.org>2010-03-05 16:17:25 -0500
commit8d59582a867470a3e0c3eced4a01625ae8dc546b (patch)
tree6f35acf842f80e3a18cdd6d644b181d4ce43f380
parentd58de038728221f780e11d50b32aa40d420c1150 (diff)
hwmon: (tmp421) Restore missing inputs
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> Cc: stable@kernel.org
-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 4f7c051e2d7b..a97e299b233b 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};
@@ -107,7 +107,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev)
107 data->config = i2c_smbus_read_byte_data(client, 107 data->config = i2c_smbus_read_byte_data(client,
108 TMP421_CONFIG_REG_1); 108 TMP421_CONFIG_REG_1);
109 109
110 for (i = 0; i <= data->kind; i++) { 110 for (i = 0; i < data->channels; i++) {
111 data->temp[i] = i2c_smbus_read_byte_data(client, 111 data->temp[i] = i2c_smbus_read_byte_data(client,
112 TMP421_TEMP_MSB[i]) << 8; 112 TMP421_TEMP_MSB[i]) << 8;
113 data->temp[i] |= i2c_smbus_read_byte_data(client, 113 data->temp[i] |= i2c_smbus_read_byte_data(client,
@@ -166,7 +166,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a,
166 devattr = container_of(a, struct device_attribute, attr); 166 devattr = container_of(a, struct device_attribute, attr);
167 index = to_sensor_dev_attr(devattr)->index; 167 index = to_sensor_dev_attr(devattr)->index;
168 168
169 if (data->kind > index) 169 if (index < data->channels)
170 return a->mode; 170 return a->mode;
171 171
172 return 0; 172 return 0;
@@ -271,7 +271,7 @@ static int tmp421_probe(struct i2c_client *client,
271 271
272 i2c_set_clientdata(client, data); 272 i2c_set_clientdata(client, data);
273 mutex_init(&data->update_lock); 273 mutex_init(&data->update_lock);
274 data->kind = id->driver_data; 274 data->channels = id->driver_data;
275 275
276 err = tmp421_init_client(client); 276 err = tmp421_init_client(client);
277 if (err) 277 if (err)