lkml.org 
[lkml]   [2026]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH v4 05/17] iio: magnetometer: ak8975: fix wrong errno on return
From: Joshua Crofts <joshua.crofts1@gmail.com>

The driver currently returns -EINVAL on polling timeout instead of
-ETIMEDOUT.

Replace return code for -ETIMEDOUT and remove unnecessary error
message as -ETIMEDOUT is a standard POSIX error. Also replace
instances of -EINVAL in comments.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/iio/magnetometer/ak8975.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 6ca8c24b9fba452b6fed8155957a8e5fcbc6511c..57f50c09cca539c3733f516a1617375e9134c349 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -662,10 +662,8 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data)
break;
timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
}
- if (!timeout_ms) {
- dev_err(&client->dev, "Conversion timeout happened\n");
- return -EINVAL;
- }
+ if (!timeout_ms)
+ return -ETIMEDOUT;

ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]);
if (ret < 0)
@@ -695,15 +693,13 @@ static int wait_conversion_complete_polled(struct ak8975_data *data)
break;
timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
}
- if (!timeout_ms) {
- dev_err(&client->dev, "Conversion timeout happened\n");
- return -EINVAL;
- }
+ if (!timeout_ms)
+ return -ETIMEDOUT;

return read_status;
}

-/* Returns 0 if the end of conversion interrupt occurred or -ETIME otherwise */
+/* Returns 0 if the end of conversion interrupt occurred or -ETIMEDOUT otherwise */
static int wait_conversion_complete_interrupt(struct ak8975_data *data)
{
int ret;
@@ -713,7 +709,7 @@ static int wait_conversion_complete_interrupt(struct ak8975_data *data)
AK8975_DATA_READY_TIMEOUT);
clear_bit(0, &data->flags);

- return ret > 0 ? 0 : -ETIME;
+ return ret > 0 ? 0 : -ETIMEDOUT;
}

static int ak8975_start_read_axis(struct ak8975_data *data,
--
2.47.3



\
 
 \ /
  Last update: 2026-05-04 11:49    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog