Skip to contentSkip to conversation

hwmon: (nct7904) Strenghten detect function

PATCH In review Guenter Roeck 3 participants 5 messages Feb 27, 2015 – Feb 28, 2015 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (nct7904) Strenghten detect function

The bank register has five unused bits. Verify that those bits are zero to strenghten the detect function.

Cc Vadim V. Vlasov <[email protected]>

---
Vadim, it would be great if you can confirm that/if this works. If yes, I'll use the same code in sensors-detect.

Thanks,
Guenter

 drivers/hwmon/nct7904.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/nct7904.c +2 -1
index eaa8234..b77b82f 100644
@@ -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);
Signature · 7 lines
2.1.0


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw

Hi Guenter!

Yes, I can confirm that the bits are always zero, even if the bank is set to an invalid number.

I used i2cset/i2cdump and regardless of the bank selection (I tried 5, 6, 0x32, 0x66 and 0xff) the higher bits are read back as zero. However, the lower bits return the selected bank number even if it is invalid (i.e. 5, 6, 2, 6 and 7 for the above tests).

The ID bytes (0x7a-0x7c) are always correct (0x50, 0xc5, 0x51) for invalid banks as well (the rest of the bytes are 0xff's).

Thanks.
Vadim.

Quoted 20 lines · Guenter Roeck

The bank register has five unused bits. Verify that those bits are zero to strenghten the detect function.

Cc Vadim V. Vlasov <[email protected]>

---
Vadim, it would be great if you can confirm that/if this works. If yes, I'll use the same code in sensors-detect.

Thanks,
Guenter

 drivers/hwmon/nct7904.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/nct7904.c +0 -0
index eaa8234..b77b82f 100644

drivers/hwmon/nct7904.c static int nct7904_detect(struct i2c_client *client, · line 509

Quoted 9 lines
drivers/hwmon/nct7904.c +2 -1
@@ -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);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author maintainer
#2 lore raw
In reply to Guenter Roeck
Quoted 11 lines · Vadim V. Vlasov

Hi Guenter!

Yes, I can confirm that the bits are always zero, even if the bank is set to an invalid number.

I used i2cset/i2cdump and regardless of the bank selection (I tried 5, 6, 0x32, 0x66 and 0xff) the higher bits are read back as zero. However, the lower bits return the selected bank number even if it is invalid (i.e. 5, 6, 2, 6 and 7 for the above tests).

That is what I suspected.

Quoted 3 lines

The ID bytes (0x7a-0x7c) are always correct (0x50, 0xc5, 0x51) for invalid banks as well (the rest of the bytes are 0xff's).

Great, thanks,

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Reviewed-by on v1 1/1
#3 lore raw
In reply to Guenter Roeck
Quoted 20 lines · Guenter Roeck

The bank register has five unused bits. Verify that those bits are zero to strenghten the detect function.

Cc Vadim V. Vlasov <[email protected]>

---
Vadim, it would be great if you can confirm that/if this works. If yes, I'll use the same code in sensors-detect.

Thanks,
Guenter

 drivers/hwmon/nct7904.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/nct7904.c +0 -0
index eaa8234..b77b82f 100644

drivers/hwmon/nct7904.c static int nct7904_detect(struct i2c_client *client, · line 509

Quoted 9 lines
drivers/hwmon/nct7904.c +2 -1
@@ -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);
Signature · 7 lines
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author maintainer
#4 lore raw
In reply to Guenter Roeck
Quoted 29 lines · Jean Delvare
Quoted 28 lines · Guenter Roeck

The bank register has five unused bits. Verify that those bits are zero to strenghten the detect function.

Cc Vadim V. Vlasov <[email protected]>

---
Vadim, it would be great if you can confirm that/if this works. If yes, I'll use the same code in sensors-detect.

Thanks,
Guenter

  drivers/hwmon/nct7904.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/nct7904.c +2 -1
index eaa8234..b77b82f 100644
@@ -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;
 
Quoted 4 lines

drivers/hwmon/nct7904.c static int nct7904_detect(struct i2c_client *client, · line 509

Quoted 1 line
drivers/hwmon/nct7904.c +0 -0
  	strlcpy(info->type, "nct7904", I2C_NAME_SIZE);

Thanks a lot!

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors