diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 22:35:57 +0300 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 22:35:57 +0300 |
commit | 52df6440a29123eed912183fe785bbe174ef14b9 (patch) | |
tree | 3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/w83793.c | |
parent | a1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (diff) | |
download | linux-52df6440a29123eed912183fe785bbe174ef14b9.tar.xz |
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/w83793.c')
-rw-r--r-- | drivers/hwmon/w83793.c | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 47dd398f7258..80a2191bf127 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c @@ -1164,7 +1164,7 @@ ERROR_SC_0: static int w83793_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) { - u8 tmp, bank; + u8 tmp, bank, chip_id; struct i2c_adapter *adapter = client->adapter; unsigned short address = client->addr; @@ -1174,44 +1174,27 @@ static int w83793_detect(struct i2c_client *client, int kind, bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); - if (kind < 0) { - tmp = bank & 0x80 ? 0x5c : 0xa3; - /* Check Winbond vendor ID */ - if (tmp != i2c_smbus_read_byte_data(client, - W83793_REG_VENDORID)) { - pr_debug("w83793: Detection failed at check " - "vendor id\n"); - return -ENODEV; - } - - /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR - should match */ - if ((bank & 0x07) == 0 - && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != - (address << 1)) { - pr_debug("w83793: Detection failed at check " - "i2c addr\n"); - return -ENODEV; - } - + tmp = bank & 0x80 ? 0x5c : 0xa3; + /* Check Winbond vendor ID */ + if (tmp != i2c_smbus_read_byte_data(client, W83793_REG_VENDORID)) { + pr_debug("w83793: Detection failed at check vendor id\n"); + return -ENODEV; } - /* We have either had a force parameter, or we have already detected the - Winbond. Determine the chip type now */ - - if (kind <= 0) { - if (0x7b == i2c_smbus_read_byte_data(client, - W83793_REG_CHIPID)) { - kind = w83793; - } else { - if (kind == 0) - dev_warn(&adapter->dev, "w83793: Ignoring " - "'force' parameter for unknown chip " - "at address 0x%02x\n", address); - return -ENODEV; - } + /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR + should match */ + if ((bank & 0x07) == 0 + && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != + (address << 1)) { + pr_debug("w83793: Detection failed at check i2c addr\n"); + return -ENODEV; } + /* Determine the chip type now */ + chip_id = i2c_smbus_read_byte_data(client, W83793_REG_CHIPID); + if (chip_id != 0x7b) + return -ENODEV; + strlcpy(info->type, "w83793", I2C_NAME_SIZE); return 0; |