aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/tmp421.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-12-09 14:35:54 -0500
committerJean Delvare <khali@linux-fr.org>2009-12-09 14:35:54 -0500
commitdbe73c8f454a40de06039ec97bc0272f41f1d3c7 (patch)
tree5bc08b0a733b5e199112d5c3bb49d3280b3a4895 /drivers/hwmon/tmp421.c
parent8f2fa77c53ba8c10696143c21b4111d449c85fb2 (diff)
hwmon: (tmp401/tmp421) Clean up detect functions
As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Andre Prendel <andre.prendel@gmx.de>
Diffstat (limited to 'drivers/hwmon/tmp421.c')
-rw-r--r--drivers/hwmon/tmp421.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
index 20924343431b..bb5464a289ca 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -223,39 +223,36 @@ static int tmp421_init_client(struct i2c_client *client)
223 return 0; 223 return 0;
224} 224}
225 225
226static int tmp421_detect(struct i2c_client *client, int kind, 226static int tmp421_detect(struct i2c_client *client, int _kind,
227 struct i2c_board_info *info) 227 struct i2c_board_info *info)
228{ 228{
229 enum chips kind;
229 struct i2c_adapter *adapter = client->adapter; 230 struct i2c_adapter *adapter = client->adapter;
230 const char *names[] = { "TMP421", "TMP422", "TMP423" }; 231 const char *names[] = { "TMP421", "TMP422", "TMP423" };
232 u8 reg;
231 233
232 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 234 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
233 return -ENODEV; 235 return -ENODEV;
234 236
235 if (kind <= 0) { 237 reg = i2c_smbus_read_byte_data(client, TMP421_MANUFACTURER_ID_REG);
236 u8 reg; 238 if (reg != TMP421_MANUFACTURER_ID)
237 239 return -ENODEV;
238 reg = i2c_smbus_read_byte_data(client, 240
239 TMP421_MANUFACTURER_ID_REG); 241 reg = i2c_smbus_read_byte_data(client, TMP421_DEVICE_ID_REG);
240 if (reg != TMP421_MANUFACTURER_ID) 242 switch (reg) {
241 return -ENODEV; 243 case TMP421_DEVICE_ID:
242 244 kind = tmp421;
243 reg = i2c_smbus_read_byte_data(client, 245 break;
244 TMP421_DEVICE_ID_REG); 246 case TMP422_DEVICE_ID:
245 switch (reg) { 247 kind = tmp422;
246 case TMP421_DEVICE_ID: 248 break;
247 kind = tmp421; 249 case TMP423_DEVICE_ID:
248 break; 250 kind = tmp423;
249 case TMP422_DEVICE_ID: 251 break;
250 kind = tmp422; 252 default:
251 break; 253 return -ENODEV;
252 case TMP423_DEVICE_ID:
253 kind = tmp423;
254 break;
255 default:
256 return -ENODEV;
257 }
258 } 254 }
255
259 strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE); 256 strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
260 dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n", 257 dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
261 names[kind - 1], client->addr); 258 names[kind - 1], client->addr);