From 413e1d6a95fcbbc048b6fce32c523e0a225275cb Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 28 Apr 2025 21:17:14 -0500 Subject: [PATCH] iio: adc: ad7606: explicit timestamp alignment MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use struct with aligned_s64 timestamp to make timestamp alignment explicit. Technically, what we have works because for all known architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64). But this way, we don't have to make people read the comments to know why there are extra elements in each buffer. Signed-off-by: David Lechner Reviewed-by: Nuno Sá Link: https://patch.msgid.link/20250428-iio-adc-ad7606-fix-buffer-alignment-v1-1-88dfc57e5df0@baylibre.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7606.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 89d49551eaf51..441e62c521bcb 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -155,12 +155,15 @@ struct ad7606_state { /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. - * 16 * 16-bit samples + 64-bit timestamp - for AD7616 - * 8 * 32-bit samples + 64-bit timestamp - for AD7616C-18 (and similar) + * 16 * 16-bit samples for AD7616 + * 8 * 32-bit samples for AD7616C-18 (and similar) */ - union { - u16 buf16[20]; - u32 buf32[10]; + struct { + union { + u16 buf16[16]; + u32 buf32[8]; + }; + aligned_s64 timestamp; } data __aligned(IIO_DMA_MINALIGN); __be16 d16[2]; }; -- 2.50.1