hwmon: (nct7904) Strenghten detect function
Guenter Roeck
maintainerPATCH 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.
---
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
@@ -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
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]>Signed-off-by Guenter Roeck <[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,
Guenterdrivers/hwmon/nct7904.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/hwmon/nct7904.c +0
-0
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
Guenter Roeck
maintainerQuoted 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,0x66and0xff) 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
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]>Signed-off-by Guenter Roeck <[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,
Guenterdrivers/hwmon/nct7904.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/hwmon/nct7904.c +0
-0
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
Guenter Roeck
maintainerQuoted 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]>Signed-off-by Guenter Roeck <[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,
Guenterdrivers/hwmon/nct7904.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)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 ;
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
-0strlcpy (info->type,"nct7904" ,I2C_NAME_SIZE );Reviewed-by Jean Delvare <[email protected]>
Thanks a lot!
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors