[PATCH] iio: accel: mc3230: Leave chip in standby on mount matrix probe failure

From: Xiangwu Lai

Date: Tue Nov 10 2026 - 02:07:25 EST


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@xxxxxxxxxxxxxxxxxxxx>
---
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");