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/lm78.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/lm78.c')
-rw-r--r-- | drivers/hwmon/lm78.c | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f7e70163e016..5978291cebb3 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -576,52 +576,34 @@ static int lm78_i2c_detect(struct i2c_client *client, int kind, | |||
576 | if (isa) | 576 | if (isa) |
577 | mutex_lock(&isa->update_lock); | 577 | mutex_lock(&isa->update_lock); |
578 | 578 | ||
579 | if (kind < 0) { | 579 | if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80) |
580 | if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80) | 580 | || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) != address) |
581 | || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) | 581 | goto err_nodev; |
582 | != address) | 582 | |
583 | goto err_nodev; | 583 | /* Explicitly prevent the misdetection of Winbond chips */ |
584 | 584 | i = i2c_smbus_read_byte_data(client, 0x4f); | |
585 | /* Explicitly prevent the misdetection of Winbond chips */ | 585 | if (i == 0xa3 || i == 0x5c) |
586 | i = i2c_smbus_read_byte_data(client, 0x4f); | 586 | goto err_nodev; |
587 | if (i == 0xa3 || i == 0x5c) | ||
588 | goto err_nodev; | ||
589 | } | ||
590 | 587 | ||
591 | /* Determine the chip type. */ | 588 | /* Determine the chip type. */ |
592 | if (kind <= 0) { | 589 | i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID); |
593 | i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID); | 590 | if (i == 0x00 || i == 0x20 /* LM78 */ |
594 | if (i == 0x00 || i == 0x20 /* LM78 */ | 591 | || i == 0x40) /* LM78-J */ |
595 | || i == 0x40) /* LM78-J */ | 592 | client_name = "lm78"; |
596 | kind = lm78; | 593 | else if ((i & 0xfe) == 0xc0) |
597 | else if ((i & 0xfe) == 0xc0) | 594 | client_name = "lm79"; |
598 | kind = lm79; | 595 | else |
599 | else { | 596 | goto err_nodev; |
600 | if (kind == 0) | ||
601 | dev_warn(&adapter->dev, "Ignoring 'force' " | ||
602 | "parameter for unknown chip at " | ||
603 | "adapter %d, address 0x%02x\n", | ||
604 | i2c_adapter_id(adapter), address); | ||
605 | goto err_nodev; | ||
606 | } | ||
607 | 597 | ||
608 | if (lm78_alias_detect(client, i)) { | 598 | if (lm78_alias_detect(client, i)) { |
609 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " | 599 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " |
610 | "be the same as ISA device\n", address); | 600 | "be the same as ISA device\n", address); |
611 | goto err_nodev; | 601 | goto err_nodev; |
612 | } | ||
613 | } | 602 | } |
614 | 603 | ||
615 | if (isa) | 604 | if (isa) |
616 | mutex_unlock(&isa->update_lock); | 605 | mutex_unlock(&isa->update_lock); |
617 | 606 | ||
618 | switch (kind) { | ||
619 | case lm79: | ||
620 | client_name = "lm79"; | ||
621 | break; | ||
622 | default: | ||
623 | client_name = "lm78"; | ||
624 | } | ||
625 | strlcpy(info->type, client_name, I2C_NAME_SIZE); | 607 | strlcpy(info->type, client_name, I2C_NAME_SIZE); |
626 | 608 | ||
627 | return 0; | 609 | return 0; |