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: vl53l0x-i2c: 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-vl53l0x-i2c-use-stack-allocated-scan-struct-v1-1-42f127a6834f@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
ff2501ff 8e7a21e1

+6 -7
+6 -7
drivers/iio/proximity/vl53l0x-i2c.c
··· 57 57 struct regulator *vdd_supply; 58 58 struct gpio_desc *reset_gpio; 59 59 struct iio_trigger *trig; 60 - 61 - struct { 62 - u16 chan; 63 - aligned_s64 timestamp; 64 - } scan; 65 60 }; 66 61 67 62 static int vl53l0x_clear_irq(struct vl53l0x_data *data) ··· 79 84 struct vl53l0x_data *data = iio_priv(indio_dev); 80 85 u8 buffer[12]; 81 86 int ret; 87 + struct { 88 + u16 chan; 89 + aligned_s64 timestamp; 90 + } scan = { }; 82 91 83 92 ret = i2c_smbus_read_i2c_block_data(data->client, 84 93 VL_REG_RESULT_RANGE_STATUS, ··· 92 93 else if (ret != 12) 93 94 return -EREMOTEIO; 94 95 95 - data->scan.chan = get_unaligned_be16(&buffer[10]); 96 - iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), 96 + scan.chan = get_unaligned_be16(&buffer[10]); 97 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 97 98 iio_get_time_ns(indio_dev)); 98 99 99 100 iio_trigger_notify_done(indio_dev->trig);