drivers/iio/accel/bma180.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
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>
---
Changes in v2:
- Preserve the struct instead of using IIO_DECLARE_BUFFER_WITH_TS()
- Did not pick up Andy's review tag since the entire patch changed.
- Link to v1: https://lore.kernel.org/r/20250710-iio-use-more-iio_declare_buffer_with_ts-v1-1-df6498f54095@baylibre.com
---
drivers/iio/accel/bma180.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 4fccbcb76e0423bee37463a72c637af80e356a19..8925f5279e627a67c8e2928b10bee04185663e10 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -139,11 +139,6 @@ struct bma180_data {
int scale;
int bw;
bool pmode;
- /* Ensure timestamp is naturally aligned */
- struct {
- s16 chan[4];
- aligned_s64 timestamp;
- } scan;
};
enum bma180_chan {
@@ -870,6 +865,10 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
struct bma180_data *data = iio_priv(indio_dev);
s64 time_ns = iio_get_time_ns(indio_dev);
int bit, ret, i = 0;
+ struct {
+ s16 chan[4];
+ aligned_s64 timestamp;
+ } scan = { };
mutex_lock(&data->mutex);
@@ -879,12 +878,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
mutex_unlock(&data->mutex);
goto err;
}
- data->scan.chan[i++] = ret;
+ scan.chan[i++] = ret;
}
mutex_unlock(&data->mutex);
- iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), time_ns);
+ iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), time_ns);
err:
iio_trigger_notify_done(indio_dev->trig);
---
base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
change-id: 20250710-iio-use-more-iio_declare_buffer_with_ts-0924382d38c6
Best regards,
--
David Lechner <dlechner@baylibre.com>
On Mon, Jul 21, 2025 at 06:16:34PM -0500, David Lechner wrote: > 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> > --- > Changes in v2: > - Preserve the struct instead of using IIO_DECLARE_BUFFER_WITH_TS() > - Did not pick up Andy's review tag since the entire patch changed. > - Link to v1: https://lore.kernel.org/r/20250710-iio-use-more-iio_declare_buffer_with_ts-v1-1-df6498f54095@baylibre.com > --- Reviewed-by: Nuno Sá <nuno.sa@analog.com> > drivers/iio/accel/bma180.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c > index 4fccbcb76e0423bee37463a72c637af80e356a19..8925f5279e627a67c8e2928b10bee04185663e10 100644 > --- a/drivers/iio/accel/bma180.c > +++ b/drivers/iio/accel/bma180.c > @@ -139,11 +139,6 @@ struct bma180_data { > int scale; > int bw; > bool pmode; > - /* Ensure timestamp is naturally aligned */ > - struct { > - s16 chan[4]; > - aligned_s64 timestamp; > - } scan; > }; > > enum bma180_chan { > @@ -870,6 +865,10 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) > struct bma180_data *data = iio_priv(indio_dev); > s64 time_ns = iio_get_time_ns(indio_dev); > int bit, ret, i = 0; > + struct { > + s16 chan[4]; > + aligned_s64 timestamp; > + } scan = { }; > > mutex_lock(&data->mutex); > > @@ -879,12 +878,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) > mutex_unlock(&data->mutex); > goto err; > } > - data->scan.chan[i++] = ret; > + scan.chan[i++] = ret; > } > > mutex_unlock(&data->mutex); > > - iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), time_ns); > + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), time_ns); > err: > iio_trigger_notify_done(indio_dev->trig); > > > --- > base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446 > change-id: 20250710-iio-use-more-iio_declare_buffer_with_ts-0924382d38c6 > > Best regards, > -- > David Lechner <dlechner@baylibre.com> >
On Tue, 22 Jul 2025 10:12:04 +0100 Nuno Sá <noname.nuno@gmail.com> wrote: > On Mon, Jul 21, 2025 at 06:16:34PM -0500, David Lechner wrote: > > 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> > > --- > > Changes in v2: > > - Preserve the struct instead of using IIO_DECLARE_BUFFER_WITH_TS() > > - Did not pick up Andy's review tag since the entire patch changed. > > - Link to v1: https://lore.kernel.org/r/20250710-iio-use-more-iio_declare_buffer_with_ts-v1-1-df6498f54095@baylibre.com > > --- > > Reviewed-by: Nuno Sá <nuno.sa@analog.com> > Applied to the testing branch of iio.git. Thanks, J
© 2016 - 2025 Red Hat, Inc.