From: David Lechner <dlechner@baylibre.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jiri Kosina" <jikos@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-input@vger.kernel.org,
David Lechner <dlechner@baylibre.com>
Subject: [PATCH 1/2] iio: add IIO_DECLARE_REPEATED_ELEMENT() macro
Date: Sat, 14 Feb 2026 15:00:20 -0600 [thread overview]
Message-ID: <20260214-iio-fix-repeat-alignment-v1-1-47f01288c803@baylibre.com> (raw)
In-Reply-To: <20260214-iio-fix-repeat-alignment-v1-0-47f01288c803@baylibre.com>
Add a new IIO_DECLARE_REPEATED_ELEMENT() macro that is used to declare
the field in an IIO buffer struct that contains a repeated element.
There are only a few iio drivers that actually make use of the .repeat
feature of struct iio_scan_type. This has an implicit rule that the
element in the buffer must be aligned to the entire size of the repeated
element. This macro will make that requirement explicit.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
include/linux/iio/iio.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 872ebdf0dd77..28b708166b9b 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -816,6 +816,19 @@ static inline void *iio_device_get_drvdata(const struct iio_dev *indio_dev)
#define IIO_DECLARE_DMA_BUFFER_WITH_TS(type, name, count) \
__IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(IIO_DMA_MINALIGN)
+/**
+ * IIO_DECLARE_REPEATED_ELEMENT() - Declare a repeated element
+ * @type: element type of the repeated element
+ * @name: identifier name of the repeated element
+ * @repeat: number of times the element is repeated
+ *
+ * For special cases with repeated elements, like IIO_MOT_QUATERNION, a multi-
+ * word element is treated as a single element of a larger size in the buffer.
+ * As such, it requires alignment to the size of the entire repeated element.
+ */
+#define IIO_DECLARE_REPEATED_ELEMENT(type, name, repeat) \
+ type name[repeat] __aligned(sizeof(type) * repeat)
+
struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);
/* The information at the returned address is guaranteed to be cacheline aligned */
--
2.43.0
next prev parent reply other threads:[~2026-02-14 21:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 21:00 [PATCH 0/2] iio: orientation: hid-sensor-rotation: fix quaternion alignment David Lechner
2026-02-14 21:00 ` David Lechner [this message]
2026-02-14 21:00 ` [PATCH 2/2] " David Lechner
2026-02-16 7:45 ` Andy Shevchenko
2026-02-24 2:35 ` Zhang, Lixu
2026-02-16 7:44 ` [PATCH 0/2] " Andy Shevchenko
2026-02-16 15:25 ` David Lechner
2026-02-17 8:10 ` Andy Shevchenko
2026-02-18 19:52 ` 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=20260214-iio-fix-repeat-alignment-v1-1-47f01288c803@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=srinivas.pandruvada@linux.intel.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
all inboxes | Powered by JetHome®