diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:54 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:54 -0500 |
commit | dbe73c8f454a40de06039ec97bc0272f41f1d3c7 (patch) | |
tree | 5bc08b0a733b5e199112d5c3bb49d3280b3a4895 /drivers/hwmon/tmp401.c | |
parent | 8f2fa77c53ba8c10696143c21b4111d449c85fb2 (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/tmp401.c')
-rw-r--r-- | drivers/hwmon/tmp401.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c index 7b34f2cd08bb..ee9673467c4a 100644 --- a/drivers/hwmon/tmp401.c +++ b/drivers/hwmon/tmp401.c | |||
@@ -488,46 +488,43 @@ static void tmp401_init_client(struct i2c_client *client) | |||
488 | i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); | 488 | i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); |
489 | } | 489 | } |
490 | 490 | ||
491 | static int tmp401_detect(struct i2c_client *client, int kind, | 491 | static int tmp401_detect(struct i2c_client *client, int _kind, |
492 | struct i2c_board_info *info) | 492 | struct i2c_board_info *info) |
493 | { | 493 | { |
494 | enum chips kind; | ||
494 | struct i2c_adapter *adapter = client->adapter; | 495 | struct i2c_adapter *adapter = client->adapter; |
496 | u8 reg; | ||
495 | 497 | ||
496 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 498 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
497 | return -ENODEV; | 499 | return -ENODEV; |
498 | 500 | ||
499 | /* Detect and identify the chip */ | 501 | /* Detect and identify the chip */ |
500 | if (kind <= 0) { | 502 | reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG); |
501 | u8 reg; | 503 | if (reg != TMP401_MANUFACTURER_ID) |
502 | 504 | return -ENODEV; | |
503 | reg = i2c_smbus_read_byte_data(client, | ||
504 | TMP401_MANUFACTURER_ID_REG); | ||
505 | if (reg != TMP401_MANUFACTURER_ID) | ||
506 | return -ENODEV; | ||
507 | |||
508 | reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); | ||
509 | |||
510 | switch (reg) { | ||
511 | case TMP401_DEVICE_ID: | ||
512 | kind = tmp401; | ||
513 | break; | ||
514 | case TMP411_DEVICE_ID: | ||
515 | kind = tmp411; | ||
516 | break; | ||
517 | default: | ||
518 | return -ENODEV; | ||
519 | } | ||
520 | 505 | ||
521 | reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | 506 | reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); |
522 | if (reg & 0x1b) | ||
523 | return -ENODEV; | ||
524 | 507 | ||
525 | reg = i2c_smbus_read_byte_data(client, | 508 | switch (reg) { |
526 | TMP401_CONVERSION_RATE_READ); | 509 | case TMP401_DEVICE_ID: |
527 | /* Datasheet says: 0x1-0x6 */ | 510 | kind = tmp401; |
528 | if (reg > 15) | 511 | break; |
529 | return -ENODEV; | 512 | case TMP411_DEVICE_ID: |
513 | kind = tmp411; | ||
514 | break; | ||
515 | default: | ||
516 | return -ENODEV; | ||
530 | } | 517 | } |
518 | |||
519 | reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | ||
520 | if (reg & 0x1b) | ||
521 | return -ENODEV; | ||
522 | |||
523 | reg = i2c_smbus_read_byte_data(client, TMP401_CONVERSION_RATE_READ); | ||
524 | /* Datasheet says: 0x1-0x6 */ | ||
525 | if (reg > 15) | ||
526 | return -ENODEV; | ||
527 | |||
531 | strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); | 528 | strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); |
532 | 529 | ||
533 | return 0; | 530 | return 0; |