Re: [PATCH v2 11/14] iio: accel: bma220: add interrupt trigger

Jonathan Cameron
2025-09-10T18:15:30Z

On Wed, 10 Sep 2025 10:57:16 +0300
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> Add interrupt trigger.
>
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>

One small thing inline,

Thanks,

Jonathan

> static irqreturn_t bma220_trigger_handler(int irq, void *p)
> {
> int ret;
> @@ -418,6 +437,25 @@ static void bma220_deinit(void *data_ptr)
> ERR_PTR(ret));
> }
>
> +static irqreturn_t bma220_irq_handler(int irq, void *private)
> +{
> + struct iio_dev *indio_dev = private;
> + struct bma220_data *data = iio_priv(indio_dev);
> + int rv;
> + u8 bma220_reg_if[2];
> +
> + guard(mutex)(&data->lock);
> + rv = regmap_bulk_read(data->regmap, BMA220_REG_IF0, bma220_reg_if,
> + sizeof(bma220_reg_if));

Given SPI needs DMA safe buffers and theory at least regmap could
have optimizations that don't bounce data in bulk accesses, please
use a DMA safe buffer here. Put one at the end of iio_priv().
Can share a cacheline with the scan.

> + if (rv)
> + return IRQ_NONE;
> +
> + if (FIELD_GET(BMA220_IF_DRDY, bma220_reg_if[1]))
> + iio_trigger_poll_nested(data->trig);
> +
> + return IRQ_HANDLED;
> +}