[PATCH v0 04/14] iio: magnetometer: ak8975: Inline timeout constants

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

Since we have switched to using macros from iopoll.h it's better to read
when the timeout values are explicitly provided in the parameters of the
respective helpers.

Besides that, fix the home grown and obviously wrong in some cases the
jiffy-based timeout.

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

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 4cc92a15e937..53987f3b13d2 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -16,6 +16,7 @@
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
+#include <linux/jiffies.h>
#include <linux/minmax.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -133,13 +134,6 @@

#define AK09912_MAX_REGS AK09912_REG_ASAZ

-/*
- * Miscellaneous values.
- */
-#define AK8975_MAX_CONVERSION_TIMEOUT 500
-#define AK8975_CONVERSION_DONE_POLL_TIME 10
-#define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000)
-
/*
* Precalculate scale factor (in Gauss units) for each axis and
* store in the device data.
@@ -658,8 +652,7 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data)

/* Wait for the conversion to complete. */
ret = readx_poll_timeout(gpiod_get_value, data->eoc_gpiod, val, val != 0,
- AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC,
- AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC);
+ 10 * USEC_PER_MSEC, 500 * USEC_PER_MSEC);
if (ret)
return ret;

@@ -678,8 +671,7 @@ static int wait_conversion_complete_polled(struct ak8975_data *data)

/* Wait for the conversion to complete. */
ret = read_poll_timeout(i2c_smbus_read_byte_data, val, val != 0,
- AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC,
- AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC,
+ 10 * USEC_PER_MSEC, 500 * USEC_PER_MSEC,
true,
client, data->def->ctrl_regs[ST1]);
if (ret)
@@ -699,7 +691,7 @@ static int wait_conversion_complete_interrupt(struct ak8975_data *data)

ret = wait_event_timeout(data->data_ready_queue,
test_bit(0, &data->flags),
- AK8975_DATA_READY_TIMEOUT);
+ msecs_to_jiffies(100));
clear_bit(0, &data->flags);

return ret > 0 ? 0 : -ETIMEDOUT;
--
2.50.1