Re: [PATCH v4 07/17] iio: magnetometer: ak8975: pass conversion timeouts as arguments

Joshua Crofts
2026-05-04T11:25:23Z

On Mon, 4 May 2026 at 13:10, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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)

Fair enough.

> 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)?

Well, considering each wait_ function is called exactly once in the code and
accepts only the hardcoded ms values (which are all positive), I think we can
change it to unsigned.

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

Okay, this was suggested by Jonathan on your v0 version, but I guess there
is no need now that there are poll and timeout parameters added in the function
(or maybe the suggestions were for the parameters only and I
misinterpreted them).

--
Kind regards

CJD