[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241114231002.98595-22-l.rubusch@gmail.com>
Date: Thu, 14 Nov 2024 23:10:01 +0000
From: Lothar Rubusch <l.rubusch@...il.com>
To: lars@...afoo.de,
Michael.Hennerich@...log.com,
jic23@...nel.org,
linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: l.rubusch@....ch,
Lothar Rubusch <l.rubusch@...il.com>
Subject: [PATCH 21/22] iio: accel: adxl345: sync FIFO reading with sensor
Pause the measurement while reading fifo values. Initially an interrupt
is triggered if watermark of the FIFO is reached, or in case of
OVERRUN. The sensor stays mute until FIFO is cleared and interrupts are
read. Situations now can arise when the watermark is configured to a
lower value. While reading the values, new values arrive such that a
permanent OVERRUN state of the FIFO is reached, i.e. either the FIFO
never gets emptied entirely because of permanently new arriving
measurements. No more interrupts will be issued and the setup results
in OVERRUN. To avoid such situation, stop measuring while solving an
OVERRUN condition and generally reading FIFO entries.
Signed-off-by: Lothar Rubusch <l.rubusch@...il.com>
---
drivers/iio/accel/adxl345_core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index ab39fd8eb5..8025dfeb84 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -714,6 +714,11 @@ static irqreturn_t adxl345_trigger_handler(int irq, void *p)
if (int_stat & (ADXL345_INT_DATA_READY | ADXL345_INT_WATERMARK)) {
pr_debug("%s(): WATERMARK or DATA_READY event detected\n", __func__);
+
+ /* Pause measuring, at low watermarks this would easily brick the
+ * sensor in permanent OVERRUN state
+ */
+ adxl345_set_measure_en(st, false);
if (adxl345_get_fifo_entries(st, &fifo_entries) < 0)
goto err;
@@ -721,12 +726,15 @@ static irqreturn_t adxl345_trigger_handler(int irq, void *p)
goto err;
iio_trigger_notify_done(indio_dev->trig);
+ adxl345_set_measure_en(st, true);
}
goto done;
err:
iio_trigger_notify_done(indio_dev->trig);
+ adxl345_set_measure_en(st, false);
adxl345_empty_fifo(st);
+ adxl345_set_measure_en(st, true);
return IRQ_NONE;
done:
--
2.39.2
Powered by blists - more mailing lists