]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: accel: adxl380: Optimize reading of FIFO entries in interrupt handler
authorFrancesco Lavra <flavra@baylibre.com>
Mon, 19 Jan 2026 10:23:17 +0000 (11:23 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 22 Jan 2026 20:53:18 +0000 (20:53 +0000)
In order to minimize the time required for transferring FIFO data from the
sensor to the host machine, perform the read from the FIFO in a single call
to regmap_noinc_read().
This allows reading acceleration data for all 3 axes at 16 kHz
sampling frequency using a 1MHz I2C bus frequency.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/adxl380.c

index a77c2323d1aa48744f854cd537b4bf72ed2ccbad..8870d22e8cdddba9a45b979d0b07986ead8a447d 100644 (file)
@@ -967,14 +967,12 @@ static irqreturn_t adxl380_irq_handler(int irq, void  *p)
                return IRQ_HANDLED;
 
        fifo_entries = rounddown(fifo_entries, st->fifo_set_size);
-       for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
-               ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA,
-                                       &st->fifo_buf[i],
-                                       2 * st->fifo_set_size);
-               if (ret)
-                       return IRQ_HANDLED;
+       ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA, &st->fifo_buf,
+                               sizeof(*st->fifo_buf) * fifo_entries);
+       if (ret)
+               return IRQ_HANDLED;
+       for (i = 0; i < fifo_entries; i += st->fifo_set_size)
                iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
-       }
 
        return IRQ_HANDLED;
 }