* [PATCH] iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct
@ 2025-07-22 22:34 David Lechner
2025-07-24 10:51 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: David Lechner @ 2025-07-22 22:34 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, David Lechner
Use a stack allocated struct for the scan data instead of using the
driver state to store the struct. The scan data is not used outside of
the interrupt handler function so the struct does not need to exist
outside of that scope.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 1deaf70e92ceb788ad8a5b82ea0bd1c28faadf1a..01c013acfda2a2d34f89248178ddf9340a77ad11 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -43,12 +43,6 @@ struct lidar_data {
int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len);
int i2c_enabled;
-
- /* Ensure timestamp is naturally aligned */
- struct {
- u16 chan;
- aligned_s64 timestamp;
- } scan;
};
static const struct iio_chan_spec lidar_channels[] = {
@@ -235,11 +229,14 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
struct iio_dev *indio_dev = pf->indio_dev;
struct lidar_data *data = iio_priv(indio_dev);
int ret;
+ struct {
+ u16 chan;
+ aligned_s64 timestamp;
+ } scan = { };
- ret = lidar_get_measurement(data, &data->scan.chan);
+ ret = lidar_get_measurement(data, &scan.chan);
if (!ret) {
- iio_push_to_buffers_with_ts(indio_dev, &data->scan,
- sizeof(data->scan),
+ iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
iio_get_time_ns(indio_dev));
} else if (ret != -EINVAL) {
dev_err(&data->client->dev, "cannot read LIDAR measurement");
---
base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
change-id: 20250722-iio-proximity-pulsedlight-lidar-lite-v2-use-stack-allocated-scan-struct-bccb4014609a
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct
2025-07-22 22:34 [PATCH] iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct David Lechner
@ 2025-07-24 10:51 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-07-24 10:51 UTC (permalink / raw)
To: David Lechner; +Cc: Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel
On Tue, 22 Jul 2025 17:34:45 -0500
David Lechner <dlechner@baylibre.com> wrote:
> Use a stack allocated struct for the scan data instead of using the
> driver state to store the struct. The scan data is not used outside of
> the interrupt handler function so the struct does not need to exist
> outside of that scope.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied to the testing branch of iio.git.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-24 10:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 22:34 [PATCH] iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct David Lechner
2025-07-24 10:51 ` Jonathan Cameron
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).