[PATCH] hwmon: (lm95241) Fix chip detection code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The LM95241 driver accepts every chip ID equal to or larger than 0xA4 as its
own, and other chips such as LM95245 use chip IDs in the accepted ID range.
This results in false chip detection.

Fix problem by accepting only the known LM95241 chip ID. Also remove the debug
message displayed if chip detection failed since it just adds noise and no real
value.

Signed-off-by: Guenter Roeck <guenter.roeck@xxxxxxxxxxxx>
---
Kept name variable to prepare for possible later addition of LM95231 support
(after I get samples).

 drivers/hwmon/lm95241.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index 1a6dfb6..f2cfecf 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -330,24 +330,19 @@ static int lm95241_detect(struct i2c_client *new_client,
 			  struct i2c_board_info *info)
 {
 	struct i2c_adapter *adapter = new_client->adapter;
-	int address = new_client->addr;
 	const char *name;
 
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -ENODEV;
 
-	if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
-	     == MANUFACTURER_ID)
-	    && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
-		>= DEFAULT_REVISION)) {
-		name = DEVNAME;
-	} else {
-		dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n",
-			address);
+	if (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
+	    != MANUFACTURER_ID
+	    || i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
+	    != DEFAULT_REVISION)
 		return -ENODEV;
-	}
 
-	/* Fill the i2c board info */
+	name = DEVNAME;
+
 	strlcpy(info->type, name, I2C_NAME_SIZE);
 	return 0;
 }
-- 
1.7.3.1


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


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux