]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct
authorDavid Lechner <dlechner@baylibre.com>
Tue, 22 Jul 2025 22:34:45 +0000 (17:34 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 16 Aug 2025 10:57:04 +0000 (11:57 +0100)
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>
Link: https://patch.msgid.link/20250722-iio-proximity-pulsedlight-lidar-lite-v2-use-stack-allocated-scan-struct-v1-1-4c253339b941@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c

index 1deaf70e92ceb788ad8a5b82ea0bd1c28faadf1a..01c013acfda2a2d34f89248178ddf9340a77ad11 100644 (file)
@@ -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");