From nobody Wed Jun 10 07:47:39 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEAFA2F7F0F for ; Sat, 16 May 2026 21:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778966382; cv=none; b=ERsBq3DNsmMZ9mcDVs6I5WQ0g4ZLg9cGSeVGriM1Gb1v870RRSG7z2nfpHn/qWYh9DsKwoQ6ECIBMdZlK5wO9z62AvNEMiwK+l77clX6Nek/3uMh5sPiHs9Jp+2GEHlw8dy3wjrY+gNfT4Oky6V15EbuhTAhWKK7smEapz8FbFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778966382; c=relaxed/simple; bh=PC79iPS+240j7MFgm/wfU2Jxq6Do9p9oBBwpT5FYjcc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=J4MF2v1pd9tcVcR2C30DQrfyP6be/6FEASobCEcw26lh4hglCRXULB7eZ2/8vwuyFu8ugxb0kHVzVJP7v3YD2Mj19EDQ6fOXgsSgTehKzXl4NwemDKsD+wdwaN622LvaUZeOEPy2uupq3NzmZ//OXFcs50cSV+NV97DrmjcreuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i142tKTF; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i142tKTF" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5a884815606so1417258e87.0 for ; Sat, 16 May 2026 14:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778966379; x=1779571179; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eqM1dQ0E8jRDZSUeqjW3SdY/BoKmGuJOH4GMYl0BB8o=; b=i142tKTFctrrRadvAdSzBak8mvVzUdHLt26mSVwnrjPou+4uBNo7pNqkIFKx8XnyUN Q79GhYHlosZPLATkNq6CLUI+HiXcefIgscpo4U7WTx0Nt89g34XhsPqNpHjraUn/rpNd rF41PEwDF2dUh4ga1B64s/nk81SmiprOLQAs/Ty2uFYmAzxt3YhxuFn/UdAi0j/RtpYH Z0pzjPw8XuI8DfL7V5NgStzadnZJgzytuIXzI3DVf73TeVSo6kBwS7kTZO3N4JDOaqN1 daQOZW9Fw9ASyoyQrbKX/oLjrt/K4PRY0Ad5FNbU5ANa6hsB8aKoJhBsrnGkuziC0BL1 Ywag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778966379; x=1779571179; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eqM1dQ0E8jRDZSUeqjW3SdY/BoKmGuJOH4GMYl0BB8o=; b=pgeTLFT2uNijk/eYUNYiMpWx8jYVI7qzOupvkk5NiMCYZV8ShH0gzEBZDVU64KP2k4 QbpuPe+f3ydxgcEweSZ0mNft9OYZXhsJrdxYmQqQnDzWDfsujJPUvDKCaUlGmMISEVFM bQltkhw793/GuBwr1DzQKkcpxYYGEVqmfdWrx27Qw+GuNpp/mzDvuZ0vqVjqZBVQObJG zjcH/lQjhRHCwtMvZPBFriQPtY3q8NYmi9QDtDaPxtEEaKbcPHfl7sNOw5L9uLzhl1lM fG1Hqnl4qzR9s6rb6G1zZyj8v+Shmz2cOLU9iu5cigBOyLYbN2GmDFwB3XHU5CK+PWaC qPDw== X-Forwarded-Encrypted: i=1; AFNElJ8jF5HjLN2F/3VSMY0aGqQ5BwNydqPCv+PbcefjRDF0jDTsKybNmiXM5RJ/s3Y9juzeOLb5Hab3a2LxzQA=@vger.kernel.org X-Gm-Message-State: AOJu0YwdeQR6MH4hSYU6YvXJQgYRzO35MJAbBZ2h9Rd0scHwphVAZMVo sW992ACMRcIOz3SE29nKZB0np4PStYK8t0Y9+cAh5yfNEGGBZ9Jomnqf X-Gm-Gg: Acq92OHx6TTC2ZBW4Cs4pDRkumFzQDI+qAQ0nKEILcVkbtYMT+CqTxnnmvBG42HdKnt H3OXUXhb0Tk3Mb5uFgl8iGYh6x+QFlJ4pCQFoo/GPUtz0pA22699q6TVFtsDDHqoAcjHNosf185 LxZejugNMoWk7QnjcB/vqchNKS8v8XaERHq5s2FXPaix1owaWC1iLsev+HCHvx4cyeTRT4W+KSO 3BNlIs10cgqDPfyzMthzXa8ZEO7eoKcFS7GbxT7qr4v5zIy155EhW4IeGqC8/58G0r3IhNCX1DF O1cBRIEEAlsenzd4L5dnu/OKE8gbumZrZAZIT7CiXNWaC2bKfLpe1Kk2Yh2O5bkqByofBtWOJt8 kC9HhalTqlxoyqkisTIzkfk/oryUgjJSumJMQAPdhzQe8DpBmoZXr7OkCKEHtFK5aAnuK54rQ33 foL5/st2o3Swut1N/fb37ohgG2NQxKKVcu1n6VfcAXqNDM4odj/bq3WNjQ X-Received: by 2002:a05:6512:1106:b0:5a8:eaeb:40ca with SMTP id 2adb3069b0e04-5aa0e7426d4mr2496920e87.31.1778966378834; Sat, 16 May 2026 14:19:38 -0700 (PDT) Received: from Shofiq.home (87-92-218-151.rev.dnainternet.fi. [87.92.218.151]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a90f10c578sm2202070e87.12.2026.05.16.14.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 14:19:37 -0700 (PDT) From: Md Shofiqul Islam To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] iio: accel: adxl372: Add timestamp to FIFO data Date: Sun, 17 May 2026 00:19:35 +0300 Message-ID: <20260516211935.36773-1-shofiqtest@gmail.com> X-Mailer: git-send-email 2.51.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver pushes FIFO samples using iio_push_to_buffers() which does not attach a hardware timestamp to the data. Capture a single timestamp per IRQ with iio_get_time_ns() and reuse it for both the event push and the FIFO sample loop. Use IIO_DECLARE_BUFFER_WITH_TS() for fifo_buf to guarantee the required s64 alignment, and switch the FIFO push loop to iio_push_to_buffers_with_ts() which accepts an explicit data size and timestamp without requiring a separate scan struct or memcpy. Add IIO_CHAN_SOFT_TIMESTAMP(3) to the channel spec so the IIO core enables scan_timestamp and includes the timestamp slot in the buffer. Signed-off-by: Md Shofiqul Islam --- Changes in v2: - Use IIO_DECLARE_BUFFER_WITH_TS() + iio_push_to_buffers_with_ts() instead of a separate scan struct + memcpy, per review from David Lechner - Add IIO_CHAN_SOFT_TIMESTAMP(3) to channel spec (missing in v1) drivers/iio/accel/adxl372.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index e375d068a..266e80e27 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -344,6 +344,7 @@ static const struct iio_chan_spec adxl372_channels[] = =3D { ADXL372_ACCEL_CHANNEL(0, ADXL372_X_DATA_H, X), ADXL372_ACCEL_CHANNEL(1, ADXL372_Y_DATA_H, Y), ADXL372_ACCEL_CHANNEL(2, ADXL372_Z_DATA_H, Z), + IIO_CHAN_SOFT_TIMESTAMP(3), }; =20 struct adxl372_state { @@ -365,7 +366,7 @@ struct adxl372_state { u8 fifo_set_size; unsigned long int1_bitmask; u16 watermark; - __be16 fifo_buf[ADXL372_FIFO_SIZE]; + IIO_DECLARE_BUFFER_WITH_TS(__be16, fifo_buf, ADXL372_FIFO_SIZE); bool peak_fifo_mode_en; struct mutex threshold_m; /* lock for threshold */ }; @@ -703,13 +704,15 @@ static irqreturn_t adxl372_trigger_handler(int irq, v= oid *p) struct adxl372_state *st =3D iio_priv(indio_dev); u8 status1, status2; u16 fifo_entries; + s64 ts; int i, ret; =20 ret =3D adxl372_get_status(st, &status1, &status2, &fifo_entries); if (ret < 0) goto err; =20 - adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2); + ts =3D iio_get_time_ns(indio_dev); + adxl372_push_event(indio_dev, ts, status2); =20 if (st->fifo_mode !=3D ADXL372_FIFO_BYPASSED && ADXL372_STATUS_1_FIFO_FULL(status1)) { @@ -733,7 +736,9 @@ static irqreturn_t adxl372_trigger_handler(int irq, voi= d *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]); + iio_push_to_buffers_with_ts(indio_dev, &st->fifo_buf[i], + st->fifo_set_size * sizeof(__be16), + ts); } } err: --=20 2.51.1