From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH v2 16/20] iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts()
Date: Sun, 6 Apr 2025 18:19:57 +0100 [thread overview]
Message-ID: <20250406172001.2167607-17-jic23@kernel.org> (raw)
In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org>
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The driver previously used an array of two s64, then type cast the
pointer to write an s16 to the start. The code is made more readable
using a structure. At the same time switch to the new
iio_push_to_buffers_with_ts() helper to enable runtime checking of the
size of the source buffer.
Note that this approach uses a structure with holes, so use memset()
to ensure those do not contain old kernel data as this data is passed
to userspace.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/iio/proximity/irsd200.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/proximity/irsd200.c b/drivers/iio/proximity/irsd200.c
index b0ffd3574013..ed15c06c8ef8 100644
--- a/drivers/iio/proximity/irsd200.c
+++ b/drivers/iio/proximity/irsd200.c
@@ -760,15 +760,19 @@ static irqreturn_t irsd200_trigger_handler(int irq, void *pollf)
{
struct iio_dev *indio_dev = ((struct iio_poll_func *)pollf)->indio_dev;
struct irsd200_data *data = iio_priv(indio_dev);
- s64 buf[2] = {};
+ struct {
+ s16 channel;
+ aligned_s64 ts;
+ } scan;
int ret;
- ret = irsd200_read_data(data, (s16 *)buf);
+ memset(&scan, 0, sizeof(scan));
+ ret = irsd200_read_data(data, &scan.channel);
if (ret)
goto end;
- iio_push_to_buffers_with_timestamp(indio_dev, buf,
- iio_get_time_ns(indio_dev));
+ iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+ iio_get_time_ns(indio_dev));
end:
iio_trigger_notify_done(indio_dev->trig);
--
2.49.0
next prev parent reply other threads:[~2025-04-06 17:21 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-06 17:19 [PATCH v2 00/20] IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 01/20] iio: adc: ad7266: Fix potential timestamp alignment issue Jonathan Cameron
2025-04-07 9:16 ` Andy Shevchenko
2025-04-07 16:23 ` Nuno Sá
2025-04-06 17:19 ` [PATCH v2 02/20] iio: adc: ad7768-1: Fix insufficient alignment of timestamp Jonathan Cameron
2025-04-07 9:16 ` Andy Shevchenko
2025-04-07 16:23 ` Nuno Sá
2025-04-06 17:19 ` [PATCH v2 03/20] iio: adc: dln2: Use aligned_s64 for timestamp Jonathan Cameron
2025-04-07 9:11 ` Andy Shevchenko
2025-04-06 17:19 ` [PATCH v2 04/20] iio: accel: adxl355: Make timestamp 64 bit aligned using aligned_s64 Jonathan Cameron
2025-04-07 9:15 ` Andy Shevchenko
2025-04-07 16:24 ` Nuno Sá
2025-04-06 17:19 ` [PATCH v2 05/20] iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument Jonathan Cameron
2025-04-07 9:18 ` Andy Shevchenko
2025-04-13 9:51 ` Jonathan Cameron
2025-04-07 16:25 ` Nuno Sá
2025-04-06 17:19 ` [PATCH v2 06/20] iio: dummy: Use a fixed structure to build up scan to push to buffers Jonathan Cameron
2025-04-07 9:23 ` Andy Shevchenko
2025-04-07 16:34 ` Nuno Sá
2025-04-13 10:05 ` Jonathan Cameron
2025-04-07 16:34 ` Nuno Sá
2025-04-13 10:05 ` Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 07/20] iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage Jonathan Cameron
2025-04-07 9:25 ` Andy Shevchenko
2025-04-07 16:37 ` Nuno Sá
2025-04-06 17:19 ` [PATCH v2 08/20] iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check Jonathan Cameron
2025-04-07 9:26 ` Andy Shevchenko
2025-04-06 17:19 ` [PATCH v2 09/20] iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-04-07 9:30 ` Andy Shevchenko
2025-04-13 10:18 ` Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 10/20] iio: accel: " Jonathan Cameron
2025-04-07 9:33 ` Andy Shevchenko
2025-04-06 17:19 ` [PATCH v2 11/20] iio: accel: hid: " Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 12/20] iio: chemical: " Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 13/20] iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 14/20] iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 15/20] iio: resolver: " Jonathan Cameron
2025-04-06 17:19 ` Jonathan Cameron [this message]
2025-04-06 17:19 ` [PATCH v2 17/20] iio: proximity: " Jonathan Cameron
2025-04-06 17:19 ` [PATCH v2 18/20] iio: pressure: zpa2326: Use aligned_s64 for the timestamp Jonathan Cameron
2025-04-06 17:20 ` [PATCH v2 19/20] iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks Jonathan Cameron
2025-04-07 11:27 ` Matti Vaittinen
2025-04-06 17:20 ` [PATCH v2 20/20] iio: magnetometer: " Jonathan Cameron
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=20250406172001.2167607-17-jic23@kernel.org \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.