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

authored by

David Lechner and committed by
Jonathan Cameron
f235ec59 83d76bf0

+7 -8
+7 -8
drivers/iio/proximity/mb1232.c
··· 42 42 */ 43 43 struct completion ranging; 44 44 int irqnr; 45 - /* Ensure correct alignment of data to push to IIO buffer */ 46 - struct { 47 - s16 distance; 48 - aligned_s64 ts; 49 - } scan; 50 45 }; 51 46 52 47 static irqreturn_t mb1232_handle_irq(int irq, void *dev_id) ··· 115 120 struct iio_poll_func *pf = p; 116 121 struct iio_dev *indio_dev = pf->indio_dev; 117 122 struct mb1232_data *data = iio_priv(indio_dev); 123 + struct { 124 + s16 distance; 125 + aligned_s64 ts; 126 + } scan = { }; 118 127 119 - data->scan.distance = mb1232_read_distance(data); 120 - if (data->scan.distance < 0) 128 + scan.distance = mb1232_read_distance(data); 129 + if (scan.distance < 0) 121 130 goto err; 122 131 123 - iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), 132 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 124 133 pf->timestamp); 125 134 126 135 err: