From: Guenter Roeck Date: Sun, 30 Jun 2024 20:08:40 +0000 (-0700) Subject: hwmon: (jc42) Strengthen detect function X-Git-Tag: v6.11-rc1~212^2~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b3e992f69c23;p=thirdparty%2Fkernel%2Flinux.git hwmon: (jc42) Strengthen detect function 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 --- diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index 1180af1b16387..a260cff750a58 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c @@ -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++) {