[PATCH v2 4/6] iio: accel: mma8452: Use dev_err_probe()

Sanjay Chitroda
2026-04-22T16:57:02Z

From: Sanjay Chitroda <sanjayembeddedse@gmail.com>

dev_err_probe() makes error code handling simpler and handle
deferred probe nicely (avoid spamming logs).

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/accel/mma8452.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 99f7763b84ac..d1ae2bf37409 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1563,8 +1563,7 @@ static int mma8452_probe(struct i2c_client *client)

data->chip_info = i2c_get_match_data(client);
if (!data->chip_info)
- return dev_err_probe(dev, -ENODEV,
- "unknown device model\n");
+ return dev_err_probe(dev, -ENODEV, "unknown device model\n");

ret = iio_read_mount_matrix(dev, &data->orientation);
if (ret)
@@ -1581,14 +1580,12 @@ static int mma8452_probe(struct i2c_client *client)
"failed to get VDDIO regulator!\n");

ret = regulator_enable(data->vdd_reg);
- if (ret) {
- dev_err(dev, "failed to enable VDD regulator!\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to enable VDD regulator!\n");

ret = regulator_enable(data->vddio_reg);
if (ret) {
- dev_err(dev, "failed to enable VDDIO regulator!\n");
+ dev_err_probe(dev, ret, "failed to enable VDDIO regulator!\n");
goto disable_regulator_vdd;
}

--
2.34.1