Skip to content

Commit

Permalink
hwmon: (lm75) Strengthen detect function
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Rob Coulson <rob.coulson@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Dec 5, 2014
1 parent b95579c commit 4ad40cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4ad40cc

Please sign in to comment.