RE: [PATCH v7 4/6] iio: adc: ad4691: add SPI offload support

Sabau, Radu bogdan
2026-04-14T10:29:21Z

> -----Original Message-----
> From: David Lechner <dlechner@baylibre.com>
> Sent: Saturday, April 11, 2026 12:01 AM

...

> >
> > static const struct ad4691_chip_info ad4694_chip_info = {
> > .name = "ad4694",
> > .max_rate = 1 * HZ_PER_MHZ,
> > .sw_info = &ad4693_sw_info,
> > + .offload_info = &ad4693_offload_info,
> > +};
> > +
> > +struct ad4691_offload_state {
> > + struct spi_offload *spi;
>
> I would call this "offload" or "instance". "spi" is usally the SPI
> device handle.

I thought about this too, will implement it as offload then.

>
> > + struct spi_offload_trigger *trigger;
> > + u64 trigger_hz;
> > + u8 tx_cmd[17][2];
> > + u8 tx_reset[4];
> > };
> >
>
> ...
>
> > +
> > +static int ad4691_cnv_burst_offload_buffer_predisable(struct iio_dev
> *indio_dev)
> > +{
> > + struct ad4691_state *st = iio_priv(indio_dev);
> > + struct ad4691_offload_state *offload = st->offload;
> > + int ret;
> > +
> > + spi_offload_trigger_disable(offload->spi, offload->trigger);
> > +
> > + ret = ad4691_sampling_enable(st, false);
> > + if (ret)
> > + return ret;
> > +
> > + ret = regmap_write(st->regmap, AD4691_STD_SEQ_CONFIG,
> > + AD4691_SEQ_ALL_CHANNELS_OFF);
>
> Why this extra step? We don't have it when unwinding in the
> error path of the postenable function.

This is a mistake from my end. Perhaps this could be removed since
the sequencer is over-written upon new buffers/raw readings anyway.

>
> > + if (ret)
> > + return ret;
> > +
> > + spi_unoptimize_message(&st->scan_msg);
> > +
> > + return ad4691_exit_conversion_mode(st);
> > +}
> > +
> > +static const struct iio_buffer_setup_ops
> ad4691_cnv_burst_offload_buffer_setup_ops = {
> > + .postenable = &ad4691_cnv_burst_offload_buffer_postenable,
> > + .predisable = &ad4691_cnv_burst_offload_buffer_predisable,
> > +};
> > +
> > static ssize_t sampling_frequency_show(struct device *dev,
> > struct device_attribute *attr,
> > char *buf)