lkml.org 
[lkml]   [2026]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 07/17] iio: magnetometer: ak8975: pass conversion timeouts as arguments
On Mon, May 04, 2026 at 11:48:19AM +0200, Joshua Crofts via B4 Relay wrote:

> Since we have switched to using macros from iopoll.h it's better to
> use poll and timeout values supplied as parameters to the helper
> functions. Also added local variables for poll and timeout values
> to prevent magic number use.
>
> Besides that, fix the home grown and obviously wrong in some cases the
> jiffy-based timeout.

...

> -static int wait_conversion_complete_gpio(struct ak8975_data *data)
> +static int wait_conversion_complete_gpio(struct ak8975_data *data, int poll_ms,
> + int timeout_ms)

Logical split is preferred:

static int wait_conversion_complete_gpio(struct ak8975_data *data,
int poll_ms, int timeout_ms)

OTOH, why are they signed? Maybe

static int wait_conversion_complete_gpio(struct ak8975_data *data,
unsigned int poll_ms,
unsigned int timeout_ms)

(but please, double check that there is no possibility to have a negative
values there)?

> + poll_ms * USEC_PER_MSEC,
> + timeout_ms * USEC_PER_MSEC);
> if (ret)
> return ret;

...

> + int irq_timeout_ms = 100;
> + int timeout_ms = 500;
> + int poll_ms = 10;

Hmm... I don't think we need those, esp. taking into account the difference in
the timeout_ms for different cases.

...

> /* Wait for the conversion to complete. */
> if (data->eoc_irq)
> - ret = wait_conversion_complete_interrupt(data);
> + ret = wait_conversion_complete_interrupt(data, irq_timeout_ms);

ret = wait_conversion_complete_interrupt(data, 100);

> else if (data->eoc_gpiod)
> - ret = wait_conversion_complete_gpio(data);
> + ret = wait_conversion_complete_gpio(data, poll_ms, timeout_ms);

ret = wait_conversion_complete_gpio(data, 10, 500);

> else
> - ret = wait_conversion_complete_polled(data);
> + ret = wait_conversion_complete_polled(data, poll_ms, timeout_ms);

ret = wait_conversion_complete_polled(data, 10, 500);

--
With Best Regards,
Andy Shevchenko



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