public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] iio: introduce IIO_DECLARE_BUFFER_WITH_TS
@ 2025-04-18 22:58 David Lechner
  2025-04-18 22:58 ` [PATCH 1/4] " David Lechner
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: David Lechner @ 2025-04-18 22:58 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Lars-Peter Clausen, Michael Hennerich
  Cc: linux-iio, linux-kernel

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. We
just 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 a new macro 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.

---
David Lechner (4):
      iio: introduce IIO_DECLARE_BUFFER_WITH_TS
      iio: adc: ad4695: use IIO_DECLARE_BUFFER_WITH_TS
      iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS
      iio: pressure: bmp280: use IIO_DECLARE_BUFFER_WITH_TS

 drivers/iio/adc/ad4695.c           |  6 ++----
 drivers/iio/adc/ad7380.c           |  4 ++--
 drivers/iio/pressure/bmp280-core.c |  8 ++++----
 drivers/iio/pressure/bmp280.h      |  3 +--
 include/linux/iio/iio.h            | 16 ++++++++++++++++
 5 files changed, 25 insertions(+), 12 deletions(-)
---
base-commit: aff301f37e220970c2f301b5c65a8bfedf52058e
change-id: 20250418-iio-introduce-iio_declare_buffer_with_ts-2f8773f7dad6

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-04-22 16:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-18 22:58 [PATCH 0/4] iio: introduce IIO_DECLARE_BUFFER_WITH_TS David Lechner
2025-04-18 22:58 ` [PATCH 1/4] " David Lechner
2025-04-19 16:33   ` Andy Shevchenko
2025-04-21 22:40     ` David Lechner
2025-04-22  6:36       ` Andy Shevchenko
2025-04-22 16:15         ` David Lechner
2025-04-19 16:35   ` Andy Shevchenko
2025-04-21 13:24   ` Nuno Sá
2025-04-18 22:58 ` [PATCH 2/4] iio: adc: ad4695: use IIO_DECLARE_BUFFER_WITH_TS David Lechner
2025-04-19 16:38   ` Andy Shevchenko
2025-04-19 17:57     ` David Lechner
2025-04-21 12:50       ` Jonathan Cameron
2025-04-18 22:58 ` [PATCH 3/4] iio: adc: ad7380: " David Lechner
2025-04-19 16:38   ` Andy Shevchenko
2025-04-19 17:59     ` David Lechner
2025-04-18 22:58 ` [PATCH 4/4] iio: pressure: bmp280: " David Lechner
2025-04-19 16:39   ` Andy Shevchenko
2025-04-19 18:04     ` David Lechner
2025-04-21 12:55       ` Jonathan Cameron
2025-04-20  4:36 ` [PATCH 0/4] iio: introduce IIO_DECLARE_BUFFER_WITH_TS Andy Shevchenko
2025-04-21 13:03   ` Jonathan Cameron
2025-04-21 15:03     ` David Lechner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox