All of lore.kernel.org
 help / color / mirror / Atom feed
From: Md Shofiqul Islam <shofiqtest@gmail.com>
To: jic23@kernel.org
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Md Shofiqul Islam <shofiqtest@gmail.com>
Subject: [PATCH 1/5] iio: accel: adxl372: Add timestamp to FIFO data
Date: Sun, 10 May 2026 11:25:52 +0300	[thread overview]
Message-ID: <20260510082556.3867-2-shofiqtest@gmail.com> (raw)
In-Reply-To: <20260510082556.3867-1-shofiqtest@gmail.com>

The driver pushes FIFO samples using iio_push_to_buffers() which does
not attach a hardware timestamp to the data.  Add a scan buffer struct
with an aligned_s64 timestamp field to the driver state, capture a
single timestamp per IRQ with iio_get_time_ns(), and switch the FIFO
push loop to iio_push_to_buffers_with_timestamp().  The same timestamp
is reused for the event push call in the same handler, replacing the
duplicate iio_get_time_ns() invocation there.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
 drivers/iio/accel/adxl372.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index 545a21e5a3..521e8313b1 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -367,6 +367,10 @@ struct adxl372_state {
 	u16				watermark;
 	__be16				fifo_buf[ADXL372_FIFO_SIZE];
 	bool				peak_fifo_mode_en;
+	struct {
+		__be16 channels[3];
+		aligned_s64 ts;
+	} scan;
 	struct mutex			threshold_m; /* lock for threshold */
 };
 
@@ -703,13 +707,15 @@ static irqreturn_t adxl372_trigger_handler(int irq, void  *p)
 	struct adxl372_state *st = iio_priv(indio_dev);
 	u8 status1, status2;
 	u16 fifo_entries;
+	s64 ts;
 	int i, ret;
 
 	ret = adxl372_get_status(st, &status1, &status2, &fifo_entries);
 	if (ret < 0)
 		goto err;
 
-	adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2);
+	ts = iio_get_time_ns(indio_dev);
+	adxl372_push_event(indio_dev, ts, status2);
 
 	if (st->fifo_mode != ADXL372_FIFO_BYPASSED &&
 	    ADXL372_STATUS_1_FIFO_FULL(status1)) {
@@ -733,7 +739,10 @@ static irqreturn_t adxl372_trigger_handler(int irq, void  *p)
 			/* filter peak detection data */
 			if (st->peak_fifo_mode_en)
 				adxl372_arrange_axis_data(st, &st->fifo_buf[i]);
-			iio_push_to_buffers(indio_dev, &st->fifo_buf[i]);
+			memcpy(st->scan.channels, &st->fifo_buf[i],
+			       st->fifo_set_size * sizeof(__be16));
+			iio_push_to_buffers_with_timestamp(indio_dev,
+							   &st->scan, ts);
 		}
 	}
 err:
-- 
2.54.0.windows.1


  reply	other threads:[~2026-05-10  8:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10  8:25 [PATCH 0/5] iio: accel: adxl3xx: Add timestamps to FIFO data Md Shofiqul Islam
2026-05-10  8:25 ` Md Shofiqul Islam [this message]
2026-05-10  8:25 ` [PATCH 2/5] iio: accel: adxl380: Add timestamp " Md Shofiqul Islam
2026-05-10  8:25 ` [PATCH 3/5] iio: accel: adxl367: " Md Shofiqul Islam
2026-05-10  8:25 ` [PATCH 4/5] iio: accel: adxl313: " Md Shofiqul Islam
2026-05-10  8:25 ` [PATCH 5/5] iio: accel: adxl345: " Md Shofiqul Islam
2026-05-10 12:58 ` [PATCH 0/5] iio: accel: adxl3xx: Add timestamps " Andy Shevchenko
     [not found]   ` <CAOTCDVsUF1qaYgSGa4hcDYOqmMpkK2G+HYeQ=ShQ1oEbM8nGJQ@mail.gmail.com>
2026-05-11 14:41     ` Jonathan Cameron
2026-05-14 18:35 ` Md Shofiqul Islam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260510082556.3867-2-shofiqtest@gmail.com \
    --to=shofiqtest@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.