[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250421121341.49e28ddf@jic23-huawei>
Date: Mon, 21 Apr 2025 12:13:41 +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 04/10] iio: adc: mxs-lradc-adc: use struct with
aligned_s64 timestamp
On Fri, 18 Apr 2025 14:58:23 -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/mxs-lradc-adc.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
> index 92baf3f5f5601b863c694eb03b6d8f287e4fe6ab..73e42f0ebcaeaaa437ba5c64ecdd7759a1191e6c 100644
> --- a/drivers/iio/adc/mxs-lradc-adc.c
> +++ b/drivers/iio/adc/mxs-lradc-adc.c
> @@ -116,7 +116,10 @@ struct mxs_lradc_adc {
>
> void __iomem *base;
> /* Maximum of 8 channels + 8 byte ts */
If we were keeping this (I think the buffer solution is better)
then we could drop that coment as to me this just became self describing code.
That's why I like these structures where we can use them with out confusion!
> - u32 buffer[10] __aligned(8);
> + struct {
> + u32 data[8];
> + aligned_u64 ts;
aligned_s64
I've not idea why timestamps are signed, but they always have been!
> + } buffer;
> struct iio_trigger *trig;
> struct completion completion;
> spinlock_t lock;
> @@ -418,14 +421,14 @@ static irqreturn_t mxs_lradc_adc_trigger_handler(int irq, void *p)
> unsigned int i, j = 0;
>
> for_each_set_bit(i, iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS) {
> - adc->buffer[j] = readl(adc->base + LRADC_CH(j));
> + adc->buffer.data[j] = readl(adc->base + LRADC_CH(j));
> writel(chan_value, adc->base + LRADC_CH(j));
> - adc->buffer[j] &= LRADC_CH_VALUE_MASK;
> - adc->buffer[j] /= LRADC_DELAY_TIMER_LOOP;
> + adc->buffer.data[j] &= LRADC_CH_VALUE_MASK;
> + adc->buffer.data[j] /= LRADC_DELAY_TIMER_LOOP;
> j++;
> }
>
> - iio_push_to_buffers_with_ts(iio, adc->buffer, sizeof(adc->buffer),
> + iio_push_to_buffers_with_ts(iio, &adc->buffer, sizeof(adc->buffer),
> pf->timestamp);
>
> iio_trigger_notify_done(iio->trig);
>
Powered by blists - more mailing lists