[PATCH v2 2/4] iio: imu: inv_icm42600: warn on whoami mismatch instead of failing probe

Jorijn van der Graaf <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
A WHOAMI value differing from the one the compatible implies aborts
probe with -ENODEV, which prevents a register-compatible part described
with a fallback compatible from probing at all.

The devicetree compatible is authoritative for which part is fitted:
demote the mismatch to a warning and continue, as st_sensors does since
commit a3c2c5c937ed ("iio: st_sensors: relax WhoAmI check in
st_sensors_verify_id()"). This changes the probe outcome on mismatch
for all parts the driver supports.

Tested via a backport to a Fairphone 6 running a 7.1-based kernel: its
ICM-42630 (WHOAMI 0x0C), described with an icm42631 fallback compatible
and matched as icm42631, warns once and probes, and accelerometer,
gyroscope and temperature reads work.

Suggested-by: Conor Dooley <[email protected]>
Link: https://lore.kernel.org/all/20260722-creature-volley-0f083b904c1d@spud/
Assisted-by: Claude:claude-fable-5
Signed-off-by: Jorijn van der Graaf <[email protected]>
---
New in v2.
 drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index dc97d8a274e3..f306e3ffca48 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -509,11 +509,9 @@ static int inv_icm42600_setup(struct inv_icm42600_state *st,
 	ret = regmap_read(st->map, INV_ICM42600_REG_WHOAMI, &val);
 	if (ret)
 		return ret;
-	if (val != hw->whoami) {
-		dev_err(dev, "invalid whoami %#02x expected %#02x (%s)\n",
-			val, hw->whoami, hw->name);
-		return -ENODEV;
-	}
+	if (val != hw->whoami)
+		dev_warn(dev, "unexpected whoami %#02x, expected %#02x (%s)\n",
+			 val, hw->whoami, hw->name);
 	st->name = hw->name;
 
 	/* reset to make sure previous state are not there */
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.