Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: proximity: pulsedlight-lidar-lite-v2: use stack allocated scan struct

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>

authored by

David Lechner and committed by
Jonathan Cameron
8e7a21e1 f235ec59

+6 -9
+6 -9
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
··· 43 43 44 44 int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len); 45 45 int i2c_enabled; 46 - 47 - /* Ensure timestamp is naturally aligned */ 48 - struct { 49 - u16 chan; 50 - aligned_s64 timestamp; 51 - } scan; 52 46 }; 53 47 54 48 static const struct iio_chan_spec lidar_channels[] = { ··· 229 235 struct iio_dev *indio_dev = pf->indio_dev; 230 236 struct lidar_data *data = iio_priv(indio_dev); 231 237 int ret; 238 + struct { 239 + u16 chan; 240 + aligned_s64 timestamp; 241 + } scan = { }; 232 242 233 - ret = lidar_get_measurement(data, &data->scan.chan); 243 + ret = lidar_get_measurement(data, &scan.chan); 234 244 if (!ret) { 235 - iio_push_to_buffers_with_ts(indio_dev, &data->scan, 236 - sizeof(data->scan), 245 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 237 246 iio_get_time_ns(indio_dev)); 238 247 } else if (ret != -EINVAL) { 239 248 dev_err(&data->client->dev, "cannot read LIDAR measurement");