Re: [PATCH v4 06/17] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros
From: Joshua Crofts
Date: Tue May 05 2026 - 03:07:54 EST
On Tue, 5 May 2026 at 06:58, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Mon, May 04, 2026 at 04:06:06PM +0100, Jonathan Cameron wrote:
> > On Mon, 04 May 2026 11:48:18 +0200
> > Joshua Crofts via B4 Relay <devnull+joshua.crofts1.gmail.com@xxxxxxxxxx> wrote:
>
> ...
>
> > One question inline on whether it is a good idea to be paranoid about
> > gpiod_get_value() potentially returning < 0 to indicate an error.
> > Right now that is treated as success.
>
> > > + 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);
> > > + if (ret)
> > > + return ret;
> >
> > Should we check val as well? It might be negative if gpiod_get_value()
> > returned an error.. Obviously the original code didn't so this would be an
> > improvement rather than maintaining what that was doing.
>
> I agree that this would be a good addition, but since it's a behavioural change
> I think the separate patch should be made (perhaps after readx_*() conversion
> as it makes it easier to do).
Good point, val should definitely be checked. Will send a fix this afternoon.
--
Kind regards
CJD