Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ad40cc5 authored by Guenter Roeck's avatar Guenter Roeck
Browse files

hwmon: (lm75) Strengthen detect function



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: default avatarRob Coulson <rob.coulson@gmail.com>
Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent b95579cd
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -415,6 +415,12 @@ static int lm75_detect(struct i2c_client *new_client,
		 || i2c_smbus_read_byte_data(new_client, 7) != os)
		 || i2c_smbus_read_byte_data(new_client, 7) != os)
			return -ENODEV;
			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 */
	/* Addresses cycling */
	for (i = 8; i <= 248; i += 40) {
	for (i = 8; i <= 248; i += 40) {