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/asb100.c | |
parent | hwmon: (w83l785ts) Clean up detect function (diff) | |
download | linux-52df6440a29123eed912183fe785bbe174ef14b9.tar.xz linux-52df6440a29123eed912183fe785bbe174ef14b9.zip |
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/asb100.c')
-rw-r--r-- | drivers/hwmon/asb100.c | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 8acf82977e7b..480f80ea1fa0 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -701,6 +701,7 @@ static int asb100_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) { struct i2c_adapter *adapter = client->adapter; + int val1, val2; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { pr_debug("asb100.o: detect failed, " @@ -708,50 +709,30 @@ static int asb100_detect(struct i2c_client *client, int kind, return -ENODEV; } - /* The chip may be stuck in some other bank than bank 0. This may - make reading other information impossible. Specify a force=... or - force_*=... parameter, and the chip will be reset to the right - bank. */ - if (kind < 0) { - - int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK); - int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); - - /* If we're in bank 0 */ - if ((!(val1 & 0x07)) && - /* Check for ASB100 ID (low byte) */ - (((!(val1 & 0x80)) && (val2 != 0x94)) || - /* Check for ASB100 ID (high byte ) */ - ((val1 & 0x80) && (val2 != 0x06)))) { - pr_debug("asb100.o: detect failed, " - "bad chip id 0x%02x!\n", val2); - return -ENODEV; - } + val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK); + val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); - } /* kind < 0 */ + /* If we're in bank 0 */ + if ((!(val1 & 0x07)) && + /* Check for ASB100 ID (low byte) */ + (((!(val1 & 0x80)) && (val2 != 0x94)) || + /* Check for ASB100 ID (high byte ) */ + ((val1 & 0x80) && (val2 != 0x06)))) { + pr_debug("asb100: detect failed, bad chip id 0x%02x!\n", val2); + return -ENODEV; + } - /* We have either had a force parameter, or we have already detected - Winbond. Put it now into bank 0 and Vendor ID High Byte */ + /* Put it now into bank 0 and Vendor ID High Byte */ i2c_smbus_write_byte_data(client, ASB100_REG_BANK, (i2c_smbus_read_byte_data(client, ASB100_REG_BANK) & 0x78) | 0x80); /* Determine the chip type. */ - if (kind <= 0) { - int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID); - int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); - - if ((val1 == 0x31) && (val2 == 0x06)) - kind = asb100; - else { - if (kind == 0) - dev_warn(&adapter->dev, "ignoring " - "'force' parameter for unknown chip " - "at adapter %d, address 0x%02x.\n", - i2c_adapter_id(adapter), client->addr); - return -ENODEV; - } - } + val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID); + val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); + + if (val1 != 0x31 || val2 != 0x06) + return -ENODEV; strlcpy(info->type, "asb100", I2C_NAME_SIZE); |