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 4/5] iio: accel: adxl313: Add timestamp to FIFO data
Date: Sun, 10 May 2026 11:25:55 +0300 [thread overview]
Message-ID: <20260510082556.3867-5-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 struct adxl313_data (in
adxl313.h), capture a timestamp with iio_get_time_ns() at the start of
adxl313_fifo_push(), and switch the push loop to
iio_push_to_buffers_with_timestamp(). The ADXL313 always scans all
three axes together so the scan buffer layout is fixed.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/iio/accel/adxl313.h | 4 ++++
drivers/iio/accel/adxl313_core.c | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/adxl313.h b/drivers/iio/accel/adxl313.h
index 75ef54b60f..ea5792fae2 100644
--- a/drivers/iio/accel/adxl313.h
+++ b/drivers/iio/accel/adxl313.h
@@ -94,6 +94,10 @@ struct adxl313_data {
u8 watermark;
__le16 transf_buf __aligned(IIO_DMA_MINALIGN);
__le16 fifo_buf[ADXL313_NUM_AXIS * ADXL313_FIFO_SIZE + 1];
+ struct {
+ __le16 channels[ADXL313_NUM_AXIS];
+ aligned_s64 ts;
+ } scan;
};
struct adxl313_chip_info {
diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index bcc11dabdf..bd45b90c42 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -1013,6 +1013,7 @@ static const struct iio_buffer_setup_ops adxl313_buffer_ops = {
static int adxl313_fifo_push(struct iio_dev *indio_dev, int samples)
{
struct adxl313_data *data = iio_priv(indio_dev);
+ s64 ts = iio_get_time_ns(indio_dev);
unsigned int i;
int ret;
@@ -1020,8 +1021,11 @@ static int adxl313_fifo_push(struct iio_dev *indio_dev, int samples)
if (ret)
return ret;
- for (i = 0; i < ADXL313_NUM_AXIS * samples; i += ADXL313_NUM_AXIS)
- iio_push_to_buffers(indio_dev, &data->fifo_buf[i]);
+ for (i = 0; i < ADXL313_NUM_AXIS * samples; i += ADXL313_NUM_AXIS) {
+ memcpy(data->scan.channels, &data->fifo_buf[i],
+ sizeof(data->scan.channels));
+ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, ts);
+ }
return 0;
}
--
2.54.0.windows.1
next prev parent reply other threads:[~2026-05-10 8:26 UTC|newest]
Thread overview: 7+ 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 ` [PATCH 1/5] iio: accel: adxl372: Add timestamp " Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 2/5] iio: accel: adxl380: " Md Shofiqul Islam
2026-05-10 8:25 ` [PATCH 3/5] iio: accel: adxl367: " Md Shofiqul Islam
2026-05-10 8:25 ` Md Shofiqul Islam [this message]
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
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-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox