]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (jc42) Strengthen detect function
authorGuenter Roeck <linux@roeck-us.net>
Sun, 30 Jun 2024 20:08:40 +0000 (13:08 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 30 Jun 2024 20:15:26 +0000 (13:15 -0700)
Configuration register bit 5 must read 0 for all JC42.4 compliant chips.
Several capability register bits must be set for all TSE2004 compliant
chips. Use that information to strengthen the detect function.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/jc42.c

index 1180af1b16387bc74008a903d15cb4703112d1ba..a260cff750a5842a289f7aeb36c2c6cd7b86cab9 100644 (file)
@@ -413,7 +413,11 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)
        if (cap < 0 || config < 0 || manid < 0 || devid < 0)
                return -ENODEV;
 
-       if ((cap & 0xff00) || (config & 0xf800))
+       if ((cap & 0xff00) || (config & 0xf820))
+               return -ENODEV;
+
+       if ((devid & TSE2004_DEVID_MASK) == TSE2004_DEVID &&
+           (cap & 0x00e7) != 0x00e7)
                return -ENODEV;
 
        for (i = 0; i < ARRAY_SIZE(jc42_chips); i++) {