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/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 2444b15f2e9d..20e0481cc206 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, | |||
556 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 556 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
557 | return -ENODEV; | 557 | return -ENODEV; |
558 | 558 | ||
559 | if (kind == 0) { | 559 | /* verify chip: reg address should match i2c address */ |
560 | kind = adm9240; | 560 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
561 | } | 561 | != address) { |
562 | 562 | dev_err(&adapter->dev, "detect fail: address match, 0x%02x\n", | |
563 | if (kind < 0) { | 563 | address); |
564 | 564 | return -ENODEV; | |
565 | /* verify chip: reg address should match i2c address */ | ||
566 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) | ||
567 | != address) { | ||
568 | dev_err(&adapter->dev, "detect fail: address match, " | ||
569 | "0x%02x\n", address); | ||
570 | return -ENODEV; | ||
571 | } | ||
572 | |||
573 | /* check known chip manufacturer */ | ||
574 | man_id = i2c_smbus_read_byte_data(new_client, | ||
575 | ADM9240_REG_MAN_ID); | ||
576 | if (man_id == 0x23) { | ||
577 | kind = adm9240; | ||
578 | } else if (man_id == 0xda) { | ||
579 | kind = ds1780; | ||
580 | } else if (man_id == 0x01) { | ||
581 | kind = lm81; | ||
582 | } else { | ||
583 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
584 | "0x%02x\n", man_id); | ||
585 | return -ENODEV; | ||
586 | } | ||
587 | |||
588 | /* successful detect, print chip info */ | ||
589 | die_rev = i2c_smbus_read_byte_data(new_client, | ||
590 | ADM9240_REG_DIE_REV); | ||
591 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
592 | man_id == 0x23 ? "ADM9240" : | ||
593 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
594 | } | 565 | } |
595 | 566 | ||
596 | /* either forced or detected chip kind */ | 567 | /* check known chip manufacturer */ |
597 | if (kind == adm9240) { | 568 | man_id = i2c_smbus_read_byte_data(new_client, ADM9240_REG_MAN_ID); |
569 | if (man_id == 0x23) { | ||
598 | name = "adm9240"; | 570 | name = "adm9240"; |
599 | } else if (kind == ds1780) { | 571 | } else if (man_id == 0xda) { |
600 | name = "ds1780"; | 572 | name = "ds1780"; |
601 | } else if (kind == lm81) { | 573 | } else if (man_id == 0x01) { |
602 | name = "lm81"; | 574 | name = "lm81"; |
575 | } else { | ||
576 | dev_err(&adapter->dev, "detect fail: unknown manuf, 0x%02x\n", | ||
577 | man_id); | ||
578 | return -ENODEV; | ||
603 | } | 579 | } |
580 | |||
581 | /* successful detect, print chip info */ | ||
582 | die_rev = i2c_smbus_read_byte_data(new_client, ADM9240_REG_DIE_REV); | ||
583 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
584 | man_id == 0x23 ? "ADM9240" : | ||
585 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
586 | |||
604 | strlcpy(info->type, name, I2C_NAME_SIZE); | 587 | strlcpy(info->type, name, I2C_NAME_SIZE); |
605 | 588 | ||
606 | return 0; | 589 | return 0; |