RE: [PATCH 2/7] iio: imu: adis: Add a kfifo buffer setup helper for FIFO devices
From: Sabau, Radu bogdan
Date: Wed Dec 02 2026 - 06:44:06 EST
> -----Original Message-----
> From: Jonathan Cameron <jic23@xxxxxxxxxx>
> Sent: Saturday, November 28, 2026 11:47 PM
...
> > Add devm_adis_setup_kfifo_buffer() for such devices. It sets up a kfifo
> > buffer and requests the FIFO interrupt as a oneshot threaded IRQ running a
> > handler supplied by the driver, which reads the FIFO and pushes the
> > samples. The interrupt is requested disabled, and the driver enables and
> > disables it with enable_irq() and disable_irq() from its buffer setup
> > functions. This is done without the adis lock, which the handler takes.
>
> Why is it masked host side rather than than device side? The rules around
> host side masking are vague and inconsistent for instance on whether
> interrupts
> that come whilst it is disabled are dropped or queued up. As a result
> device side masking is much preferred.
>
The pin cannot be masked in the device on these parts.
The interrupts are level triggered, so nothing is lost or queued while
masked on the host. I will explain it in the commit message in v2.
More in my reply to patch 6.
>
> >
> > The trigger/current_trigger attribute is user visible on the existing FIFO
> > devices, so add devm_adis_register_fifo_trigger() for them to keep it. It
> > registers a trigger with the usual name and sets
> INDIO_HARDWARE_TRIGGERED
...
> > +{
> > + int ret;
> > +
> > + ret = devm_iio_kfifo_buffer_setup_ext(&adis->spi->dev, indio_dev,
> ops,
> > + buffer_attrs);
>
> Does it work without the irq?
No. Without an interrupt nothing would fill the buffer.
In v2 the helper will fail without an interrupt, and the adis16475 will only
call it when there is one, so devices without one keep working as now,
just without a buffer.
>
> > + if (ret)
> > + return ret;
> > +
...
> > + * Registers an IIO trigger named after the device. It is never used to push
> > + * samples, as the data goes to a kfifo buffer. It only keeps the
> > + * trigger/current_trigger interface of devices that always had it, so writing
> > + * it is accepted but has no effect. New drivers do not need it.
>
> We want to keep the current_trigger interface for existing parts but
> not add it for new ones. There can't be a regression on devices we haven't
> supported yet. So I think we either need to push the setting of
> INDIO_HARDWARE_TRIGGERED to the caller or have multiple helpers for
> the different cases.
Agreed, I will move the trigger registration into the adis16475 driver,
and only for the six FIFO variants that already had it, through a flag in
their chip info.