RE: [PATCH v13 3/6] iio: adc: ad4691: add triggered buffer support

From: Sabau, Radu bogdan

Date: Mon May 25 2026 - 08:32:14 EST




> -----Original Message-----
> From: Sabau, Radu bogdan <Radu.Sabau@xxxxxxxxxx>
> Sent: Monday, May 25, 2026 3:02 PM

...

> > + * ad4691_exit_conversion_mode - Return the chip to AUTONOMOUS
> mode.
> > + *
> > + * Called from buffer postdisable to restore the chip to the
> > + * idle state used by read_raw. Clears the sequencer and resets state.
> > + */
> > +static int ad4691_exit_conversion_mode(struct ad4691_state *st)
> > +{
> > + if (st->manual_mode)
> > + return regmap_update_bits(st->regmap,
> > AD4691_DEVICE_SETUP,
> > + AD4691_MANUAL_MODE, 0);
>
> Once again, and I hate to say this, a follow-up patch will be required.
>
> Somewhere along the patch versions ad4691_transfer which was used for
> removed functionality from the driver was removed and was used to send
> 0x5000 (SPI command to exit MANUAL MODE and come back into
> Autonomous Mode which in Manual Mode is used for raw_reading).
>
> At the time being this is a bug that means once using the buffer and stopping
> it, register access to the device doesn't really exist anymore and the SPI
> operations
> used for register access can not be relied on.
>
> I am very sorry for finding this out just now, I guess I focused too much on OSR
> and
> CNV Burst Mode lately that I completely forgot about this.
>
> Will leave this patch here to see if any further review comes in and will also
> take a look
> at Sashiko , perhaps he finds something else and a v14 will be needed anyway.

Just for reference, this is how the new code would look like, not too much of a
difference:

#define AD4691_EXIT_COMMAND 0x5000

...

static int ad4691_transfer(struct ad4691_state *st, u16 cmd)
{
u8 buf[2];

put_unaligned_be16(cmd, buf);

return spi_write(st->spi, buf, sizeof(buf));
}

...

static int ad4691_exit_conversion_mode(struct ad4691_state *st)
{
if (st->manual_mode)
- return regmap_update_bits(st->regmap, AD4691_DEVICE_SETUP,
- AD4691_MANUAL_MODE, 0);
+ return ad4691_transfer(st, AD4691_EXIT_COMMAND);