public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Eugen Hristev" <eugen.hristev@linaro.org>,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	"Andreas Klinger" <ak@it-klinger.de>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH 00/10] iio: prefer aligned_s64 timestamp (round 1)
Date: Mon, 21 Apr 2025 12:17:52 +0100	[thread overview]
Message-ID: <20250421121752.5a7a178e@jic23-huawei> (raw)
In-Reply-To: <abe0db44-b27f-4cea-9edc-862e4096f80c@baylibre.com>

On Fri, 18 Apr 2025 18:05:42 -0500
David Lechner <dlechner@baylibre.com> wrote:

> On 4/18/25 2:58 PM, David Lechner wrote:
> > While reviewing the recent conversion to iio_push_to_buffers_with_ts(),
> > I found it very time-consuming to check the correctness of the buffers
> > passed to that function when they used an array with extra room at the
> > end for a timestamp. And we still managed find a few that were wrongly
> > sized or not properly aligned despite several efforts in the past to
> > audit these for correctness already.
> > 
> > Even though these ones look to be correct, it will still be easier for
> > future readers of the code if we follow the pattern of using a struct
> > with the array and timestamp instead.
> > 
> > For example, it is much easier to see that:
> > 
> > struct {
> > 	__be32 data[3];
> > 	aligned_s64 timestamp;
> > } buffer;
> >   
> After sending [1], I realized that some (perhaps many) of these would actually
> be a better candidate for the proposed IIO_DECLARE_BUFFER_WITH_TS macro rather
> that converting to the struct style as above.
> 
> Case in point: if the driver using that struct allows reading only one channel,
> then the offset of the timestamp when doing iio_push_to_buffers_with_ts() would
> be 8 bytes, not 16, so the struct would not always be the correct layout.
> 
> As long as the driver doesn't access the timestamp member of the struct, it
> doesn't really matter, but this could be a bit misleading to anyone who might
> unknowing try to use it in the future.
Agreed.  

These timestamp inserting functions have always been a bit weird. I kind
of regret not just leaving it as a per driver thing to do, but that ship
long sailed.  I definitely want to keep the layout apparent in the drivers
though so this approach only applied to 1 of the ones in this series.

Jonathan

> 
> [1]: https://lore.kernel.org/linux-iio/20250418-iio-introduce-iio_declare_buffer_with_ts-v1-0-ee0c62a33a0f@baylibre.com/



      reply	other threads:[~2025-04-21 11:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 19:58 [PATCH 00/10] iio: prefer aligned_s64 timestamp (round 1) David Lechner
2025-04-18 19:58 ` [PATCH 01/10] iio: accel: sca3300: use struct with aligned_s64 timestamp David Lechner
2025-04-18 19:58 ` [PATCH 02/10] iio: adc: at91-sama5d2_adc: " David Lechner
2025-04-21 11:10   ` Jonathan Cameron
2025-04-18 19:58 ` [PATCH 03/10] iio: adc: hx711: " David Lechner
2025-04-21 11:11   ` Jonathan Cameron
2025-04-18 19:58 ` [PATCH 04/10] iio: adc: mxs-lradc-adc: " David Lechner
2025-04-21 11:13   ` Jonathan Cameron
2025-04-21 16:41     ` Andy Shevchenko
2025-04-18 19:58 ` [PATCH 05/10] iio: adc: stm32-adc: " David Lechner
2025-04-18 19:58 ` [PATCH 06/10] iio: adc: ti-adc0832: " David Lechner
2025-04-21 11:15   ` Jonathan Cameron
2025-04-18 19:58 ` [PATCH 07/10] iio: adc: ti-adc12138: " David Lechner
2025-04-18 19:58 ` [PATCH 08/10] iio: adc: ti-ads124s08: " David Lechner
2025-04-18 19:58 ` [PATCH 09/10] iio: adc: ti-ads8688: " David Lechner
2025-04-18 19:58 ` [PATCH 10/10] iio: chemical: atlas-sensor: " David Lechner
2025-04-18 23:05 ` [PATCH 00/10] iio: prefer aligned_s64 timestamp (round 1) David Lechner
2025-04-21 11:17   ` Jonathan Cameron [this message]

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=20250421121752.5a7a178e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andy@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dlechner@baylibre.com \
    --cc=eugen.hristev@linaro.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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