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: accel: bma180: use stack allocated buffer for scan

Move the scan struct to the stack instead of being in the driver state
struct. The buffer is only used in a single function and does not need
to be DMA-safe so it does not need to exist outside of that function's
scope.

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-v2-1-f8fb11b8add8@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
97b262d2 c9100ef6

+6 -7
+6 -7
drivers/iio/accel/bma180.c
··· 139 139 int scale; 140 140 int bw; 141 141 bool pmode; 142 - /* Ensure timestamp is naturally aligned */ 143 - struct { 144 - s16 chan[4]; 145 - aligned_s64 timestamp; 146 - } scan; 147 142 }; 148 143 149 144 enum bma180_chan { ··· 865 870 struct bma180_data *data = iio_priv(indio_dev); 866 871 s64 time_ns = iio_get_time_ns(indio_dev); 867 872 int bit, ret, i = 0; 873 + struct { 874 + s16 chan[4]; 875 + aligned_s64 timestamp; 876 + } scan = { }; 868 877 869 878 mutex_lock(&data->mutex); 870 879 ··· 878 879 mutex_unlock(&data->mutex); 879 880 goto err; 880 881 } 881 - data->scan.chan[i++] = ret; 882 + scan.chan[i++] = ret; 882 883 } 883 884 884 885 mutex_unlock(&data->mutex); 885 886 886 - iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), time_ns); 887 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), time_ns); 887 888 err: 888 889 iio_trigger_notify_done(indio_dev->trig); 889 890