Re: [PATCH] iio: accel: adxl380: fix FIFO watermark bit 8 always written as 0

From: Andy Shevchenko

Date: Mon Mar 02 2026 - 10:08:24 EST


On Mon, Mar 02, 2026 at 08:54:52AM -0600, David Lechner wrote:
> On 3/2/26 1:56 AM, Andy Shevchenko wrote:
> > On Sat, Feb 28, 2026 at 10:50:00AM -0600, David Lechner wrote:
> >> On 2/27/26 6:43 AM, Antoniu Miclaus wrote:

...

> >>> + !!(fifo_samples & BIT(8))));
> >>
> >> Technically, this works, but in terms of understanding the code I think
> >> fifo_samples >= BIT(8) would make more sense.
> >>
> >> fifo_samples is a count, not bit flags.
> >
> > I even would prefer to see in such a case
> >
> > fifo_samples > (BIT(8) - 1)
> >
> > that it will define the maximum that fits the HW, or plain number
> >
> > fifo_samples > 127
>
> Now that I looked at the dataheet, I get Jonathan's point.
>
> The reason this is here is that we are filling in a 9-bit value
> using 8-bit registers, so the MSB goes in a different register.
>
> So actually, it would probably make the most sense to write
> it as `fifo_samples >> 8`.

I agree based on the above justification.

--
With Best Regards,
Andy Shevchenko