All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function
@ 2015-02-27 16:36 Guenter Roeck
  2015-02-27 17:27 ` Vadim V. Vlasov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Guenter Roeck @ 2015-02-27 16:36 UTC (permalink / raw)
  To: lm-sensors

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

Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
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(-)

diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
index eaa8234..b77b82f 100644
--- a/drivers/hwmon/nct7904.c
+++ b/drivers/hwmon/nct7904.c
@@ -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);
-- 
2.1.0


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function
  2015-02-27 16:36 [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function Guenter Roeck
@ 2015-02-27 17:27 ` Vadim V. Vlasov
  2015-02-27 21:30 ` Guenter Roeck
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Vadim V. Vlasov @ 2015-02-27 17:27 UTC (permalink / raw)
  To: 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.

On Fri, 2015-02-27 at 08:36 -0800, Guenter Roeck wrote:
> The bank register has five unused bits. Verify that those bits are zero
> to strenghten the detect function.
> 
> Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 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(-)
> 
> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
> index eaa8234..b77b82f 100644
> --- a/drivers/hwmon/nct7904.c
> +++ b/drivers/hwmon/nct7904.c
> @@ -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
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function
  2015-02-27 16:36 [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function Guenter Roeck
  2015-02-27 17:27 ` Vadim V. Vlasov
@ 2015-02-27 21:30 ` Guenter Roeck
  2015-02-27 22:05 ` Jean Delvare
  2015-02-28  2:05 ` Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2015-02-27 21:30 UTC (permalink / raw)
  To: lm-sensors

On Fri, Feb 27, 2015 at 08:27:04PM +0300, Vadim V. Vlasov wrote:
> 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.

> 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
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function
  2015-02-27 16:36 [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function Guenter Roeck
  2015-02-27 17:27 ` Vadim V. Vlasov
  2015-02-27 21:30 ` Guenter Roeck
@ 2015-02-27 22:05 ` Jean Delvare
  2015-02-28  2:05 ` Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2015-02-27 22:05 UTC (permalink / raw)
  To: lm-sensors

On Fri, 27 Feb 2015 08:36:19 -0800, Guenter Roeck wrote:
> The bank register has five unused bits. Verify that those bits are zero
> to strenghten the detect function.
> 
> Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 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(-)
> 
> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
> index eaa8234..b77b82f 100644
> --- a/drivers/hwmon/nct7904.c
> +++ b/drivers/hwmon/nct7904.c
> @@ -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);

Reviewed-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function
  2015-02-27 16:36 [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function Guenter Roeck
                   ` (2 preceding siblings ...)
  2015-02-27 22:05 ` Jean Delvare
@ 2015-02-28  2:05 ` Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2015-02-28  2:05 UTC (permalink / raw)
  To: lm-sensors

On 02/27/2015 02:05 PM, Jean Delvare wrote:
> On Fri, 27 Feb 2015 08:36:19 -0800, Guenter Roeck wrote:
>> The bank register has five unused bits. Verify that those bits are zero
>> to strenghten the detect function.
>>
>> Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
>> index eaa8234..b77b82f 100644
>> --- a/drivers/hwmon/nct7904.c
>> +++ b/drivers/hwmon/nct7904.c
>> @@ -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);
>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
>
Thanks a lot!

Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-28  2:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 16:36 [lm-sensors] [PATCH] hwmon: (nct7904) Strenghten detect function Guenter Roeck
2015-02-27 17:27 ` Vadim V. Vlasov
2015-02-27 21:30 ` Guenter Roeck
2015-02-27 22:05 ` Jean Delvare
2015-02-28  2:05 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.