Re: [PATCH v7 3/6] iio: adc: ad4691: add triggered buffer support

From: Jonathan Cameron

Date: Sun Apr 12 2026 - 13:44:38 EST


On Fri, 10 Apr 2026 15:46:36 -0500
David Lechner <dlechner@xxxxxxxxxxxx> wrote:

> On 4/9/26 10:28 AM, Radu Sabau via B4 Relay wrote:
> > From: Radu Sabau <radu.sabau@xxxxxxxxxx>
> >
> > Add buffered capture support using the IIO triggered buffer framework.
> >
>
> ...
>
> > @@ -201,8 +245,45 @@ struct ad4691_state {
> > * atomicity of consecutive SPI operations.
> > */
> > struct mutex lock;
> > + /*
> > + * Per-buffer-enable lifetime resources:
> > + * Manual Mode - a pre-built SPI message that clocks out N+1
> > + * transfers in one go.
> > + * CNV Burst Mode - a pre-built SPI message that clocks out 2*N
> > + * transfers in one go.
> > + */
> > + struct spi_message scan_msg;
> > + /* max 16 + 1 NOOP (manual) or 2*16 + 2 (CNV burst). */
> > + struct spi_transfer scan_xfers[34];
> > + /*
> > + * CNV burst: 16 AVG_IN addresses + state-reset address + state-reset
> > + * value = 18. Manual: 16 channel cmds + 1 NOOP = 17.
> > + */
> > + __be16 scan_tx[18];
>
> Needs __aligned(IIO_DMA_MINALIGN) since it is used with SPI.
As below.
>
> > + /* Scan buffer: one BE16 slot per channel (rx'd directly), plus timestamp */
> > + struct {
> > + __be16 vals[16];
> > + aligned_s64 ts;
> > + } scan;
>
> Unless it is required that all channels are always enabled:
>
> IIO_DECLARE_BUFFER_WITH_TS(__be16, scan_rx, 16);
>
> In any case, needs to be DMA-safe for SPI.
Custom regmap that uses spi_write_then_read() for all cases so it
should be bounced anyway.

Perhaps a comment to that affect would be useful.

J