Re: [PATCH 2/2] iio: light: adux1020: extract the FIFO byte count with FIELD_GET()

From: Jonathan Cameron

Date: Sat Nov 14 2026 - 19:03:45 EST


On Mon, 09 Nov 2026 11:39:03 +0000
Raffaele Tranfaglia via B4 Relay <devnull+raffaele.tranfaglia.gmail.com@xxxxxxxxxx> wrote:

> From: Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>
>
> adux1020_measure() masks INT_STATUS with ADUX1020_FIFO_STATUS_MASK but
> does not shift the result down, so it compares 256 times the FIFO byte
> count against the packet size. A count of 1 would thus be treated as a
> complete 2-byte proximity packet.
>
> This does not happen on a correctly working device, because the FIFO
> only stores complete packets and the driver always reads complete
> packets, so the count is always a multiple of the packet size. Still,
> use FIELD_GET() so the comparison matches the datasheet's polling
> procedure and does not depend on that.
>
> Signed-off-by: Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>
Applied this one to the testing branch of iio.git

Thanks

Jonathan

> ---
> drivers/iio/light/adux1020.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/adux1020.c b/drivers/iio/light/adux1020.c
> index cccd509dd18a..dd5230c6dceb 100644
> --- a/drivers/iio/light/adux1020.c
> +++ b/drivers/iio/light/adux1020.c
> @@ -331,7 +331,7 @@ static int adux1020_measure(struct adux1020_data *data,
> if (ret < 0)
> return ret;
>
> - status &= ADUX1020_FIFO_STATUS_MASK;
> + status = FIELD_GET(ADUX1020_FIFO_STATUS_MASK, status);
> if (status >= adux1020_modes[mode].bytes)
> break;
> msleep(20);
>