[PATCH v0 12/14] iio: magnetometer: ak8975: Unify messages with help of dev_err_probe()

Andy Shevchenko
2026-04-27T20:14:28Z

Unify error messages that might appear during probe phase by
switching to use dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/magnetometer/ak8975.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index b734a5939f73..c2eb7b0d0da8 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -495,10 +495,8 @@ static int ak8975_who_i_am(const struct ak8975_data *data,
AK09912_REG_WIA1,
sizeof(wia_val),
wia_val);
- if (ret < 0) {
- dev_err(&client->dev, "Error reading WIA\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&client->dev, ret, "Error reading WIA\n");

if (wia_val[0] != AK8975_DEVICE_ID)
return -ENODEV;
@@ -971,18 +969,14 @@ static int ak8975_probe(struct i2c_client *client)
return ret;

ret = ak8975_who_i_am(data, data->def->type);
- if (ret) {
- dev_err(&client->dev, "Unexpected device\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Unexpected device\n");
dev_dbg(&client->dev, "Asahi compass chip %s\n", name);

/* Perform some basic start-of-day setup of the device. */
ret = ak8975_setup(data);
- if (ret) {
- dev_err(&client->dev, "%s initialization fails\n", name);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "%s initialization fails\n", name);

ret = devm_mutex_init(dev, &data->lock);
if (ret)
@@ -997,16 +991,12 @@ static int ak8975_probe(struct i2c_client *client)

ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
ak8975_handle_trigger, NULL);
- if (ret) {
- dev_err(&client->dev, "triggered buffer setup failed\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "triggered buffer setup failed\n");

ret = devm_iio_device_register(dev, indio_dev);
- if (ret) {
- dev_err(&client->dev, "device register failed\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "device register failed\n");

/* Enable runtime PM */
ret = devm_pm_runtime_set_active_enabled(dev);
--
2.50.1