Re: [PATCH] iio: adc: ad4000: Avoid potential double data word read

From: Andy Shevchenko
Date: Wed Apr 16 2025 - 02:48:48 EST


On Wed, Apr 16, 2025 at 09:01:02AM +0300, Andy Shevchenko wrote:
> On Wed, Apr 16, 2025 at 8:59 AM Andy Shevchenko
> <andy.shevchenko@xxxxxxxxx> wrote:
> > On Wed, Apr 16, 2025 at 12:22 AM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> > > On 4/15/25 1:02 PM, Andy Shevchenko wrote:

...

> > > It would have to be:
> > >
> > > xfers[1].len = roundup_pow_of_two(BITS_TO_BYTES(chan->scan_type.realbits));
> > >
> > > But that gets too long for 1 line
> >
> > Actually there are a handful of drivers including SPI core that need
> > that helper already, I would prefer to have a helper defined in spi.h.
> >
> > , so I prefer what Marcelo wrote.
> > >
> > > Maybe an idea for another day:
> > >
> > > #define SPI_LEN_FOR_BITS(bits) roundup_pow_of_two(BITS_TO_BYTES(bits))
> >
> > Right, but as static inline to have stricter types.
> >
> > > There are a couple of places in spi/ that could use this and several
> > > iio drivers.
>
> Or even wider, in bitops.h / bit*.h somewhere. Let me craft a patch.

Just sent a mini-series, you are in Cc there.

--
With Best Regards,
Andy Shevchenko