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: srf08: use stack allocated scan buffer

Use a stack allocated scan struct in srf08_trigger_handler(). Since the
scan buffer isn't used outside of this function and doesn't need to be
DMA-safe, it doesn't need to be in struct srf08_data. We can also
eliminate an extra local variable for the return value of
srf08_read_ranging() by using scan.chan directly.

Reviewed-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250721-iio-use-more-iio_declare_buffer_with_ts-6-v2-1-8b66e5b4e75a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
c9100ef6 5335f93d

+7 -11
+7 -11
drivers/iio/proximity/srf08.c
··· 63 63 int range_mm; 64 64 struct mutex lock; 65 65 66 - /* Ensure timestamp is naturally aligned */ 67 - struct { 68 - s16 chan; 69 - aligned_s64 timestamp; 70 - } scan; 71 - 72 66 /* Sensor-Type */ 73 67 enum srf08_sensor_type sensor_type; 74 68 ··· 176 182 struct iio_poll_func *pf = p; 177 183 struct iio_dev *indio_dev = pf->indio_dev; 178 184 struct srf08_data *data = iio_priv(indio_dev); 179 - s16 sensor_data; 185 + struct { 186 + s16 chan; 187 + aligned_s64 timestamp; 188 + } scan = { }; 180 189 181 - sensor_data = srf08_read_ranging(data); 182 - if (sensor_data < 0) 190 + scan.chan = srf08_read_ranging(data); 191 + if (scan.chan < 0) 183 192 goto err; 184 193 185 194 mutex_lock(&data->lock); 186 195 187 - data->scan.chan = sensor_data; 188 - iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), 196 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 189 197 pf->timestamp); 190 198 191 199 mutex_unlock(&data->lock);