hwmon: (nct7904) Strengthen detect function
authorGuenter Roeck <linux@roeck-us.net>
Fri, 27 Feb 2015 16:23:37 +0000 (08:23 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 9 Mar 2015 16:59:36 +0000 (09:59 -0700)
The bank register has five unused bits. Verify that those bits are zero
to strengthen the detect function.

Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
drivers/hwmon/nct7904.c

index eaa8234..b77b82f 100644 (file)
@@ -502,7 +502,8 @@ static int nct7904_detect(struct i2c_client *client,
        /* Determine the chip type. */
        if (i2c_smbus_read_byte_data(client, VENDOR_ID_REG) != NUVOTON_ID ||
            i2c_smbus_read_byte_data(client, CHIP_ID_REG) != NCT7904_ID ||
-           (i2c_smbus_read_byte_data(client, DEVICE_ID_REG) & 0xf0) != 0x50)
+           (i2c_smbus_read_byte_data(client, DEVICE_ID_REG) & 0xf0) != 0x50 ||
+           (i2c_smbus_read_byte_data(client, BANK_SEL_REG) & 0xf8) != 0x00)
                return -ENODEV;
 
        strlcpy(info->type, "nct7904", I2C_NAME_SIZE);