[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250421121519.4189bd3d@jic23-huawei>
Date: Mon, 21 Apr 2025 12:15:19 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Nuno Sá <nuno.sa@...log.com>, Andy Shevchenko
<andy@...nel.org>, Eugen Hristev <eugen.hristev@...aro.org>, Nicolas Ferre
<nicolas.ferre@...rochip.com>, Alexandre Belloni
<alexandre.belloni@...tlin.com>, Claudiu Beznea <claudiu.beznea@...on.dev>,
Andreas Klinger <ak@...klinger.de>, Shawn Guo <shawnguo@...nel.org>, Sascha
Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team
<kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>, Maxime
Coquelin <mcoquelin.stm32@...il.com>, Alexandre Torgue
<alexandre.torgue@...s.st.com>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
imx@...ts.linux.dev, linux-stm32@...md-mailman.stormreply.com
Subject: Re: [PATCH 06/10] iio: adc: ti-adc0832: use struct with aligned_s64
timestamp
On Fri, 18 Apr 2025 14:58:25 -0500
David Lechner <dlechner@...libre.com> wrote:
> Use a struct with aligned s64_timestamp instead of a padded array for
> the buffer used for iio_push_to_buffers_with_ts(). This makes it easier
> to see the correctness of the size and alignment of the buffer.
>
> Signed-off-by: David Lechner <dlechner@...libre.com>
> ---
> drivers/iio/adc/ti-adc0832.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c
> index cfcdafbe284b103a069857028886411bc72dea4f..f508f7113faa2610a2889f3c36c5a679fa72264d 100644
> --- a/drivers/iio/adc/ti-adc0832.c
> +++ b/drivers/iio/adc/ti-adc0832.c
> @@ -10,6 +10,7 @@
> #include <linux/module.h>
> #include <linux/mod_devicetable.h>
> #include <linux/spi/spi.h>
> +#include <linux/types.h>
> #include <linux/iio/iio.h>
> #include <linux/regulator/consumer.h>
> #include <linux/iio/buffer.h>
> @@ -29,12 +30,10 @@ struct adc0832 {
> struct regulator *reg;
> struct mutex lock;
> u8 mux_bits;
> - /*
> - * Max size needed: 16x 1 byte ADC data + 8 bytes timestamp
> - * May be shorter if not all channels are enabled subject
> - * to the timestamp remaining 8 byte aligned.
If the comment is going, we need to capture that there are 16 channels
via a define or a comment.
This one probably wants to stay as a buffer but the same will apply to a new
patch doing that.
> - */
> - u8 data[24] __aligned(8);
> + struct {
> + u8 data[16];
> + aligned_s64 timestamp;
> + } buffer;
>
> u8 tx_buf[2] __aligned(IIO_DMA_MINALIGN);
> u8 rx_buf[2];
> @@ -222,10 +221,10 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p)
> goto out;
> }
>
> - adc->data[i] = ret;
> + adc->buffer.data[i] = ret;
> i++;
> }
> - iio_push_to_buffers_with_ts(indio_dev, adc->data, sizeof(adc->data),
> + iio_push_to_buffers_with_ts(indio_dev, &adc->buffer, sizeof(adc->buffer),
> iio_get_time_ns(indio_dev));
> out:
> mutex_unlock(&adc->lock);
>
Powered by blists - more mailing lists