diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
commit | 52df6440a29123eed912183fe785bbe174ef14b9 (patch) | |
tree | 3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/lm87.c | |
parent | a1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (diff) |
hwmon: 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: Corentin Labbe <corentin.labbe@geomatys.fr>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Juerg Haefliger <juergh@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Acked-by: "Hans J. Koch" <hjk@linutronix.de>
Cc: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r-- | drivers/hwmon/lm87.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 2e4a3cea95f7..4929b1815eee 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -666,37 +666,32 @@ static int lm87_detect(struct i2c_client *new_client, int kind, | |||
666 | struct i2c_board_info *info) | 666 | struct i2c_board_info *info) |
667 | { | 667 | { |
668 | struct i2c_adapter *adapter = new_client->adapter; | 668 | struct i2c_adapter *adapter = new_client->adapter; |
669 | static const char *names[] = { "lm87", "adm1024" }; | 669 | const char *name; |
670 | u8 cid, rev; | ||
670 | 671 | ||
671 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 672 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
672 | return -ENODEV; | 673 | return -ENODEV; |
673 | 674 | ||
674 | /* Default to an LM87 if forced */ | 675 | if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) |
675 | if (kind == 0) | 676 | return -ENODEV; |
676 | kind = lm87; | ||
677 | 677 | ||
678 | /* Now, we do the remaining detection. */ | 678 | /* Now, we do the remaining detection. */ |
679 | if (kind < 0) { | 679 | cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); |
680 | u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); | 680 | rev = lm87_read_value(new_client, LM87_REG_REVISION); |
681 | u8 rev = lm87_read_value(new_client, LM87_REG_REVISION); | 681 | |
682 | 682 | if (cid == 0x02 /* National Semiconductor */ | |
683 | if (cid == 0x02 /* National Semiconductor */ | 683 | && (rev >= 0x01 && rev <= 0x08)) |
684 | && (rev >= 0x01 && rev <= 0x08)) | 684 | name = "lm87"; |
685 | kind = lm87; | 685 | else if (cid == 0x41 /* Analog Devices */ |
686 | else if (cid == 0x41 /* Analog Devices */ | 686 | && (rev & 0xf0) == 0x10) |
687 | && (rev & 0xf0) == 0x10) | 687 | name = "adm1024"; |
688 | kind = adm1024; | 688 | else { |
689 | 689 | dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n", | |
690 | if (kind < 0 | 690 | new_client->addr); |
691 | || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) { | 691 | return -ENODEV; |
692 | dev_dbg(&adapter->dev, | ||
693 | "LM87 detection failed at 0x%02x.\n", | ||
694 | new_client->addr); | ||
695 | return -ENODEV; | ||
696 | } | ||
697 | } | 692 | } |
698 | 693 | ||
699 | strlcpy(info->type, names[kind - 1], I2C_NAME_SIZE); | 694 | strlcpy(info->type, name, I2C_NAME_SIZE); |
700 | 695 | ||
701 | return 0; | 696 | return 0; |
702 | } | 697 | } |