From: "Nuno Sá" <noname.nuno@gmail.com>
To: "David Lechner" <dlechner@baylibre.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Eugen Hristev" <eugen.hristev@linaro.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Trevor Gamblin <tgamblin@baylibre.com>
Subject: Re: [PATCH v5 0/7] iio: introduce IIO_DECLARE_BUFFER_WITH_TS
Date: Wed, 07 May 2025 07:39:07 +0100 [thread overview]
Message-ID: <ec7c00c640b0b359bfd98d460d067aee64ca069f.camel@gmail.com> (raw)
In-Reply-To: <20250505-iio-introduce-iio_declare_buffer_with_ts-v5-0-814b72b1cae3@baylibre.com>
On Mon, 2025-05-05 at 11:31 -0500, David Lechner wrote:
> Creating a buffer of the proper size and correct alignment for use with
> iio_push_to_buffers_with_ts() is commonly used and not easy to get
> right (as seen by a number of recent fixes on the mailing list).
>
> In general, we prefer to use this pattern for creating such buffers:
>
> struct {
> u16 data[2];
> aligned_s64 timestamp;
> } buffer;
>
> However, there are many cases where a driver may have a large number of
> channels that can be optionally enabled or disabled in a scan or the
> driver might support a range of chips that have different numbers of
> channels or different storage sizes for the data. In these cases, the
> timestamp may not always be at the same place relative to the data. To
> handle these, we allocate a buffer large enough for the largest possible
> case and don't care exactly where the timestamp ends up in the buffer.
>
> For these cases, we propose to introduce new macros to make it easier
> it easier for both the authors to get it right and for readers of the
> code to not have to do all of the math to verify that it is correct.
>
> I have just included a few examples of drivers that can make use of this
> new macro, but there are dozens more.
>
> ---
LGTM
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Changes in v5:
> - Add new patch to set minimum alignment to 8 for IIO_DMA_MINALIGN.
> - Adjust IIO_DECLARE_DMA_BUFFER_WITH_TS() macro for above change.
> - Drop one ad4695 patch that was already applied.
> - Link to v4:
> https://lore.kernel.org/r/20250428-iio-introduce-iio_declare_buffer_with_ts-v4-0-6f7f6126f1cb@baylibre.com
>
> Changes in v4:
> - Dropped static_assert()s from the first patch.
> - Handle case when IIO_DMA_MINALIGN < sizeof(timestamp).
> - Added one more patch for ad4695 to rename a confusing macro.
> - Link to v3:
> https://lore.kernel.org/r/20250425-iio-introduce-iio_declare_buffer_with_ts-v3-0-f12df1bff248@baylibre.com
>
> Changes in v3:
> - Fixed a few mistakes, style issues and incorporate other feedback (see
> individual commit message changelogs for details).
> - Link to v2:
> https://lore.kernel.org/r/20250422-iio-introduce-iio_declare_buffer_with_ts-v2-0-3fd36475c706@baylibre.com
>
> Changes in v2:
> - Add 2nd macro for case where we need DMA alignment.
> - Add new patch for ad4695 to convert buffer from u8 to u16 before
> making use of the new macro.
> - Drop the bmp280 patch since it was determined to have a better
> alternative not using these macros.
> - Add a few more examples to show the non-DMA case, both in a struct and
> stack allocated.
> - Link to v1:
> https://lore.kernel.org/r/20250418-iio-introduce-iio_declare_buffer_with_ts-v1-0-ee0c62a33a0f@baylibre.com
>
> ---
> David Lechner (7):
> iio: make IIO_DMA_MINALIGN minimum of 8 bytes
> iio: introduce IIO_DECLARE_BUFFER_WITH_TS macros
> iio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS
> iio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS
> iio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS
> iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS
> iio: adc: at91-sama5d2: use IIO_DECLARE_BUFFER_WITH_TS
>
> drivers/iio/accel/sca3300.c | 18 ++--------------
> drivers/iio/adc/ad4695.c | 11 +++++-----
> drivers/iio/adc/ad7380.c | 3 +--
> drivers/iio/adc/at91-sama5d2_adc.c | 13 ++----------
> include/linux/iio/iio.h | 42 ++++++++++++++++++++++++++++++++++++++
> 5 files changed, 52 insertions(+), 35 deletions(-)
> ---
> base-commit: 7e9a82ab5b861d3c33c99a22c1245a5b262ee502
> change-id: 20250418-iio-introduce-iio_declare_buffer_with_ts-2f8773f7dad6
>
> Best regards,
next prev parent reply other threads:[~2025-05-07 8:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 16:31 [PATCH v5 0/7] iio: introduce IIO_DECLARE_BUFFER_WITH_TS David Lechner
2025-05-05 16:31 ` [PATCH v5 1/7] iio: make IIO_DMA_MINALIGN minimum of 8 bytes David Lechner
2025-05-07 20:02 ` Jonathan Cameron
2025-05-08 21:39 ` David Laight
2025-05-08 21:44 ` David Lechner
2025-05-05 16:31 ` [PATCH v5 2/7] iio: introduce IIO_DECLARE_BUFFER_WITH_TS macros David Lechner
2025-05-05 16:31 ` [PATCH v5 3/7] iio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS David Lechner
2025-05-05 16:31 ` [PATCH v5 4/7] iio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS David Lechner
2025-05-05 16:31 ` [PATCH v5 5/7] iio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS David Lechner
2025-05-05 16:31 ` [PATCH v5 6/7] iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS David Lechner
2025-05-07 6:37 ` Nuno Sá
2025-05-05 16:31 ` [PATCH v5 7/7] iio: adc: at91-sama5d2: " David Lechner
2025-05-05 16:47 ` [PATCH v5 0/7] iio: introduce IIO_DECLARE_BUFFER_WITH_TS Jonathan Cameron
2025-05-07 6:39 ` Nuno Sá [this message]
2025-05-07 19:54 ` Jonathan Cameron
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=ec7c00c640b0b359bfd98d460d067aee64ca069f.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andy@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=dlechner@baylibre.com \
--cc=eugen.hristev@linaro.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=nuno.sa@analog.com \
--cc=tgamblin@baylibre.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;
as well as URLs for NNTP newsgroup(s).