[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250722-iio-use-more-iio_declare_buffer_with_ts-8-v1-1-36188a3f214f@baylibre.com>
Date: Tue, 22 Jul 2025 17:54:07 -0500
From: David Lechner <dlechner@...libre.com>
To: Jonathan Cameron <jic23@...nel.org>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
David Lechner <dlechner@...libre.com>
Subject: [PATCH] iio: proximity: hx9023s: use IIO_DECLARE_BUFFER_WITH_TS()
Use stack-allocated IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer
that gets used with iio_push_to_buffers_with_ts().
We change from a struct to IIO_DECLARE_BUFFER_WITH_TS() since
HX9023S_CH_NUM is 5 making channels[] larger than 8 bytes and therefore
the timestamp is not always as the same position depending on the number
of channels enabled in the scan.
And since the data structure is not used outside of the scope of the
interrupt handler, the array does not need to be in the driver state
struct and can just be stack-allocated.
Signed-off-by: David Lechner <dlechner@...libre.com>
---
drivers/iio/proximity/hx9023s.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index 33781c3147286fb3e2f022201ccf7e908d0b6b12..1203fa4bc7512ea85b55d537e2459104b52407b9 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -143,12 +143,6 @@ struct hx9023s_data {
unsigned long chan_in_use;
unsigned int prox_state_reg;
bool trigger_enabled;
-
- struct {
- __le16 channels[HX9023S_CH_NUM];
- aligned_s64 ts;
- } buffer;
-
/*
* Serialize access to registers below:
* HX9023S_PROX_INT_LOW_CFG,
@@ -928,6 +922,7 @@ static const struct iio_trigger_ops hx9023s_trigger_ops = {
static irqreturn_t hx9023s_trigger_handler(int irq, void *private)
{
+ IIO_DECLARE_BUFFER_WITH_TS(__le16, channels, HX9023S_CH_NUM);
struct iio_poll_func *pf = private;
struct iio_dev *indio_dev = pf->indio_dev;
struct hx9023s_data *data = iio_priv(indio_dev);
@@ -950,11 +945,11 @@ static irqreturn_t hx9023s_trigger_handler(int irq, void *private)
iio_for_each_active_channel(indio_dev, bit) {
index = indio_dev->channels[bit].channel;
- data->buffer.channels[i++] = cpu_to_le16(data->ch_data[index].diff);
+ channels[i++] = cpu_to_le16(data->ch_data[index].diff);
}
- iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
- sizeof(data->buffer), pf->timestamp);
+ iio_push_to_buffers_with_ts(indio_dev, channels, sizeof(channels),
+ pf->timestamp);
out:
iio_trigger_notify_done(indio_dev->trig);
---
base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
change-id: 20250722-iio-use-more-iio_declare_buffer_with_ts-8-57ebd3c8af19
Best regards,
--
David Lechner <dlechner@...libre.com>
Powered by blists - more mailing lists