mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: accel: mc3230: Leave chip in standby on mount matrix probe failure
@ 2026-11-10  7:02 Xiangwu Lai
  2026-11-12 20:12 ` Arnav Kapoor
  0 siblings, 1 reply; 2+ messages in thread
From: Xiangwu Lai @ 2026-11-10  7:02 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Xiangwu Lai

mc3230_probe() switches the chip to WAKE mode before reading the
mount matrix from firmware, but when the mount matrix cannot be read
it returns directly and leaves the chip in WAKE mode.  The
iio_device_register() failure path, in contrast, correctly puts the
chip back into STANDBY, so the mount matrix error path is clearly
missing the same cleanup.

The mount matrix is read from firmware only and does not need the
chip at all, so move it before the WAKE transition.  That way the
chip is only woken up once the remaining steps cannot fail anymore.

Fixes: e59c6acfd5fa ("iio: accel: mc3230: add mount matrix support")
Signed-off-by: laixiangwu <laixiangwu@cmss.chinamobile.com>
---
 drivers/iio/accel/mc3230.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index b45897210..9ee71da7e 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -183,14 +183,14 @@ static int mc3230_probe(struct i2c_client *client)
 	indio_dev->channels = mc3230_channels;
 	indio_dev->num_channels = ARRAY_SIZE(mc3230_channels);
 
-	ret = mc3230_set_opcon(data, MC3230_MODE_OPCON_WAKE);
-	if (ret < 0)
-		return ret;
-
 	ret = iio_read_mount_matrix(&client->dev, &data->orientation);
 	if (ret)
 		return ret;
 
+	ret = mc3230_set_opcon(data, MC3230_MODE_OPCON_WAKE);
+	if (ret < 0)
+		return ret;
+
 	ret = iio_device_register(indio_dev);
 	if (ret < 0) {
 		dev_err(&client->dev, "device_register failed\n");



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-12 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  7:02 [PATCH] iio: accel: mc3230: Leave chip in standby on mount matrix probe failure Xiangwu Lai
2026-11-12 20:12 ` Arnav Kapoor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®