linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	linux-iio@vger.kernel.org,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: "Mudit Sharma" <muditsharma.info@gmail.com>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
	"Abhash Jha" <abhashkumarjha123@gmail.com>,
	"Astrid Rost" <astrid.rost@axis.com>,
	"Mårten Lindahl" <marten.lindahl@axis.com>,
	"Gwendal Grignou" <gwendal@chromium.org>,
	"Christian Eggers" <ChristianEggersceggers@arri.de>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 04/16] iio: light: vcnl4035: Use a structure to make buffer arrangement explicit.
Date: Mon, 4 Aug 2025 09:52:58 +0300	[thread overview]
Message-ID: <3299b85c-82d2-465a-a4cf-38a06b710804@gmail.com> (raw)
In-Reply-To: <20250802164436.515988-5-jic23@kernel.org>

On 02/08/2025 19:44, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Using a structure to arrange the data to be passed to
> iio_push_to_buffers_with_timestamp() makes the placement and padding
> explicit, removing the need for comments to explain what is going on.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>   drivers/iio/light/vcnl4035.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
> index 79ec41b60530..dca229e74725 100644
> --- a/drivers/iio/light/vcnl4035.c
> +++ b/drivers/iio/light/vcnl4035.c
> @@ -103,7 +103,10 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
>   	struct iio_dev *indio_dev = pf->indio_dev;
>   	struct vcnl4035_data *data = iio_priv(indio_dev);
>   	/* Ensure naturally aligned timestamp */
> -	u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)]  __aligned(8) = { };
> +	struct {
> +		u16 chan;
> +		aligned_s64 ts;
> +	} scan;
>   	int val;
>   	int ret;
>   
> @@ -113,8 +116,8 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
>   			"Trigger consumer can't read from sensor.\n");
>   		goto fail_read;
>   	}
> -	*((u16 *)buffer) = val;
> -	iio_push_to_buffers_with_timestamp(indio_dev, buffer,
> +	scan.chan = val;
> +	iio_push_to_buffers_with_timestamp(indio_dev, &scan,
>   					iio_get_time_ns(indio_dev));
>   
>   fail_read:

I suppose I was too hasty commenting the previous patch :) Besides, I 
misread the buffer definition. I just thought there were room for the 
u16 and couple of s64s. Hence I suggested a packed struct...

Now, re-reading this and seeing your patch - this looks correct :)

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

Yours,
	-- Matti

  reply	other threads:[~2025-08-04  6:53 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-02 16:44 [PATCH 00/16] IIO: Enable runtime checks on buffers size and related Jonathan Cameron
2025-08-02 16:44 ` [PATCH 01/16] iio: light: as73211: Ensure buffer holes are zeroed Jonathan Cameron
2025-08-04  6:39   ` Matti Vaittinen
2025-08-02 16:44 ` [PATCH 02/16] iio: light: vcnl4035: Fix endianness vs data placement in buffer issue Jonathan Cameron
2025-08-03 19:16   ` Andy Shevchenko
2025-08-16 14:46     ` Jonathan Cameron
2025-08-04  6:38   ` Matti Vaittinen
2025-08-02 16:44 ` [PATCH 03/16] iio: light: as73211: Use iio_push_to_buffers_with_ts() to allow source size runtime check Jonathan Cameron
2025-08-02 16:44 ` [PATCH 04/16] iio: light: vcnl4035: Use a structure to make buffer arrangement explicit Jonathan Cameron
2025-08-04  6:52   ` Matti Vaittinen [this message]
2025-08-02 16:44 ` [PATCH 05/16] iio: light: vcnl4035: Use iio_push_to_buffers_with_ts() to allow runtime source buffer size check Jonathan Cameron
2025-08-04  6:57   ` Matti Vaittinen
2025-08-16 14:48     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 06/16] iio: light: acpi-als: Use a structure for layout of data to push to buffer Jonathan Cameron
2025-08-03 19:24   ` Andy Shevchenko
2025-08-16 14:50     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 07/16] iio: light: acpi-als: Use iio_push_to_buffers_with_ts() to allow runtime source size check Jonathan Cameron
2025-08-16 14:52   ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 08/16] iio: light: adjd_s311: Use iio_push_to_buffers_with_ts() to allow source size runtime check Jonathan Cameron
2025-08-04  7:04   ` Matti Vaittinen
2025-08-16 14:52     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 09/16] iio: light: isl29125: " Jonathan Cameron
2025-08-04  7:06   ` Matti Vaittinen
2025-08-16 14:52     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 10/16] iio: light: max44000: " Jonathan Cameron
2025-08-03 19:26   ` Andy Shevchenko
2025-08-16 14:55     ` Jonathan Cameron
2025-08-04  7:08   ` Matti Vaittinen
2025-08-02 16:44 ` [PATCH 11/16] iio: light: st_uvis25: " Jonathan Cameron
2025-08-04  7:09   ` Matti Vaittinen
2025-08-16 14:56     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 12/16] iio: light: tcs3414: " Jonathan Cameron
2025-08-16 14:57   ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 13/16] iio: light: tcs3472: " Jonathan Cameron
2025-08-16 14:58   ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 14/16] iio: light: vcnl4000: Use a structure to make buffer arrangement explicit Jonathan Cameron
2025-08-04  7:00   ` Mårten Lindahl
2025-08-16 14:59     ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 15/16] iio: light: vl6180: Use iio_push_to_buffers_with_ts() to allow source size runtime check Jonathan Cameron
2025-08-16 14:59   ` Jonathan Cameron
2025-08-02 16:44 ` [PATCH 16/16] iio: light: Simple conversions to iio_push_to_buffers_with_ts() Jonathan Cameron
2025-08-04  8:01   ` Matti Vaittinen
2025-08-04 13:29   ` srinivas pandruvada
2025-08-16 15:00     ` Jonathan Cameron
2025-08-03 19:43 ` [PATCH 00/16] IIO: Enable runtime checks on buffers size and related Andy Shevchenko

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=3299b85c-82d2-465a-a4cf-38a06b710804@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=ChristianEggersceggers@arri.de \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=abhashkumarjha123@gmail.com \
    --cc=andy@kernel.org \
    --cc=astrid.rost@axis.com \
    --cc=dlechner@baylibre.com \
    --cc=gwendal@chromium.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jic23@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=marten.lindahl@axis.com \
    --cc=muditsharma.info@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).