diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 20:35:57 +0100 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 20:35:57 +0100 |
commit | 52df6440a29123eed912183fe785bbe174ef14b9 (patch) | |
tree | 3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/adm9240.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/adm9240.c')
-rw-r--r-- | drivers/hwmon/adm9240.c | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 2444b15f2e9..20e0481cc20 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -556,51 +556,34 @@ static int adm9240_detect(struct i2c_client *new_client, int kind, if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - if (kind == 0) { - kind = adm9240; - } - - if (kind < 0) { - - /* verify chip: reg address should match i2c address */ - if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) - != address) { - dev_err(&adapter->dev, "detect fail: address match, " - "0x%02x\n", address); - return -ENODEV; - } - - /* check known chip manufacturer */ - man_id = i2c_smbus_read_byte_data(new_client, - ADM9240_REG_MAN_ID); - if (man_id == 0x23) { - kind = adm9240; - } else if (man_id == 0xda) { - kind = ds1780; - } else if (man_id == 0x01) { - kind = lm81; - } else { - dev_err(&adapter->dev, "detect fail: unknown manuf, " - "0x%02x\n", man_id); - return -ENODEV; - } - - /* successful detect, print chip info */ - die_rev = i2c_smbus_read_byte_data(new_client, - ADM9240_REG_DIE_REV); - dev_info(&adapter->dev, "found %s revision %u\n", - man_id == 0x23 ? "ADM9240" : - man_id == 0xda ? "DS1780" : "LM81", die_rev); + /* verify chip: reg address should match i2c address */ + if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) + != address) { + dev_err(&adapter->dev, "detect fail: address match, 0x%02x\n", + address); + return -ENODEV; } - /* either forced or detected chip kind */ - if (kind == adm9240) { + /* check known chip manufacturer */ + man_id = i2c_smbus_read_byte_data(new_client, ADM9240_REG_MAN_ID); + if (man_id == 0x23) { name = "adm9240"; - } else if (kind == ds1780) { + } else if (man_id == 0xda) { name = "ds1780"; - } else if (kind == lm81) { + } else if (man_id == 0x01) { name = "lm81"; + } else { + dev_err(&adapter->dev, "detect fail: unknown manuf, 0x%02x\n", + man_id); + return -ENODEV; } + + /* successful detect, print chip info */ + die_rev = i2c_smbus_read_byte_data(new_client, ADM9240_REG_DIE_REV); + dev_info(&adapter->dev, "found %s revision %u\n", + man_id == 0x23 ? "ADM9240" : + man_id == 0xda ? "DS1780" : "LM81", die_rev); + strlcpy(info->type, name, I2C_NAME_SIZE); return 0; |