From: David Lechner <dlechner@baylibre.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
David Lechner <dlechner@baylibre.com>
Subject: [PATCH] iio: proximity: sx_common: use stack allocated buffer for scan data
Date: Fri, 11 Jul 2025 10:55:07 -0500 [thread overview]
Message-ID: <20250711-iio-use-more-iio_declare_buffer_with_ts-5-v1-1-4209f54e010f@baylibre.com> (raw)
Use IIO_DECLARE_BUFFER_WITH_TS() to declare a stack allocated buffer
in sx_common_trigger_handler(). Since the scan buffer isn't used outside
of this function and doesn't need to be DMA-safe, it doesn't need to be
in struct sx_common_data.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/proximity/sx_common.c | 7 ++++---
drivers/iio/proximity/sx_common.h | 6 ------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
index 59b35e40739b0d931dbac076ca5c83ba421ba766..fae035e8d2f5a40ed7379dd6e306f84878a9bef0 100644
--- a/drivers/iio/proximity/sx_common.c
+++ b/drivers/iio/proximity/sx_common.c
@@ -361,6 +361,7 @@ static irqreturn_t sx_common_irq_thread_handler(int irq, void *private)
static irqreturn_t sx_common_trigger_handler(int irq, void *private)
{
+ IIO_DECLARE_BUFFER_WITH_TS(__be16, buffer, SX_COMMON_MAX_NUM_CHANNELS);
struct iio_poll_func *pf = private;
struct iio_dev *indio_dev = pf->indio_dev;
struct sx_common_data *data = iio_priv(indio_dev);
@@ -376,11 +377,11 @@ static irqreturn_t sx_common_trigger_handler(int irq, void *private)
if (ret)
goto out;
- data->buffer.channels[i++] = val;
+ buffer[i++] = val;
}
- iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
- sizeof(data->buffer), pf->timestamp);
+ iio_push_to_buffers_with_ts(indio_dev, buffer, sizeof(buffer),
+ pf->timestamp);
out:
mutex_unlock(&data->mutex);
diff --git a/drivers/iio/proximity/sx_common.h b/drivers/iio/proximity/sx_common.h
index 259b5c695233b4e295ad8ae2b05fceeaa4a7ae61..97b264aa50b0c9811ce6b42be34eace03eae2627 100644
--- a/drivers/iio/proximity/sx_common.h
+++ b/drivers/iio/proximity/sx_common.h
@@ -122,12 +122,6 @@ struct sx_common_data {
unsigned long chan_prox_stat;
bool trigger_enabled;
- /* Ensure correct alignment of timestamp when present. */
- struct {
- __be16 channels[SX_COMMON_MAX_NUM_CHANNELS];
- aligned_s64 ts;
- } buffer;
-
unsigned int suspend_ctrl;
unsigned long chan_read;
unsigned long chan_event;
---
base-commit: f8f559752d573a051a984adda8d2d1464f92f954
change-id: 20250711-iio-use-more-iio_declare_buffer_with_ts-5-f4c91d73037d
Best regards,
--
David Lechner <dlechner@baylibre.com>
next reply other threads:[~2025-07-11 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 15:55 David Lechner [this message]
2025-07-11 16:42 ` [PATCH] iio: proximity: sx_common: use stack allocated buffer for scan data Andy Shevchenko
2025-07-13 13:59 ` 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=20250711-iio-use-more-iio_declare_buffer_with_ts-5-v1-1-4209f54e010f@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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 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).