All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (lm75) Strengthen detect function
Date: Fri, 05 Dec 2014 14:14:00 +0000	[thread overview]
Message-ID: <5481BDA8.6000108@roeck-us.net> (raw)
In-Reply-To: <1417716250-14598-1-git-send-email-linux@roeck-us.net>

On 12/05/2014 03:57 AM, Jean Delvare wrote:
> Hi Guenter,
>
> On Thu,  4 Dec 2014 10:04:10 -0800, Guenter Roeck wrote:
>> A chip returning 0x00 in all registers is erroneously detected
>> as LM75. Check hysteresis and temperature limit registers and
>> abort if both are 0 to reduce the likelyhood for this to happen.
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   drivers/hwmon/lm75.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
>> index f58439b..6753fd9 100644
>> --- a/drivers/hwmon/lm75.c
>> +++ b/drivers/hwmon/lm75.c
>> @@ -415,6 +415,12 @@ static int lm75_detect(struct i2c_client *new_client,
>>   		 || i2c_smbus_read_byte_data(new_client, 7) != os)
>>   			return -ENODEV;
>>   	}
>> +	/*
>> +	 * It is very unlikely that this is a LM75 if both
>> +	 * hysteresis and temperature limit registers are 0.
>> +	 */
>> +	if (hyst = 0 && os = 0)
>> +		return -ENODEV;
>>
>>   	/* Addresses cycling */
>>   	for (i = 8; i <= 248; i += 40) {
>
> Looks reasonable.
>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
>
> Did sensors-detect misdetect that chip as an LM75 too, or was the
> extended detection logic there good enough already?
>

Hi Jean,

sensors-detect is fine. Easy to test -load i2c-stub and see what
happens. I assume that is due to the "All registers hold same value"
test. Should I use that test instead ? I kind of prefer it.

Thanks,
Guenter


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

  parent reply	other threads:[~2014-12-05 14:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 18:04 [lm-sensors] [PATCH] hwmon: (lm75) Strengthen detect function Guenter Roeck
2014-12-04 20:16 ` Robert Coulson
2014-12-04 21:08 ` Guenter Roeck
2014-12-04 23:49 ` Robert Coulson
2014-12-05 11:57 ` Jean Delvare
2014-12-05 14:14 ` Guenter Roeck [this message]
2014-12-05 15:15 ` Jean Delvare
2014-12-05 16:47 ` Guenter Roeck
2014-12-06 12:12 ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5481BDA8.6000108@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.