diff options
Diffstat (limited to 'drivers/hwmon/thmc50.c')
-rw-r--r-- | drivers/hwmon/thmc50.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index 7d97431..1db9bc8 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c @@ -289,7 +289,6 @@ static int thmc50_detect(struct i2c_client *client, int kind, unsigned revision; unsigned config; struct i2c_adapter *adapter = client->adapter; - int err = 0; const char *type_name; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -301,31 +300,13 @@ static int thmc50_detect(struct i2c_client *client, int kind, pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n", client->addr, i2c_adapter_id(client->adapter)); - /* Now, we do the remaining detection. */ company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID); revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE); config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); + if (revision < 0xc0 || (config & 0x10)) + return -ENODEV; - if (kind == 0) - kind = thmc50; - else if (kind < 0) { - err = -ENODEV; - if (revision >= 0xc0 && ((config & 0x10) == 0)) { - if (company == 0x49) { - kind = thmc50; - err = 0; - } else if (company == 0x41) { - kind = adm1022; - err = 0; - } - } - } - if (err == -ENODEV) { - pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n"); - return err; - } - - if (kind == adm1022) { + if (company == 0x41) { int id = i2c_adapter_id(client->adapter); int i; @@ -340,9 +321,13 @@ static int thmc50_detect(struct i2c_client *client, int kind, config); break; } - } else { + } else if (company == 0x49) { type_name = "thmc50"; + } else { + pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n"); + return -ENODEV; } + pr_debug("thmc50: Detected %s (version %x, revision %x)\n", type_name, (revision >> 4) - 0xc, revision & 0xf); |