On Thu, 28 Mar 2024 14:22:25 +0100 Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@xxxxxxxxxx> wrote: > From: Nuno Sa <nuno.sa@xxxxxxxxxx> > > Simple helper for setting the buffer direction when it's allocated using > iio_dmaengine_buffer_alloc(). > > Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx> I wonder if we should align with the approach for triggered-buffers with and _ext form of the registration function that takes a direction. It seems odd to allocate one then change the direction. Jonathan > --- > drivers/iio/industrialio-buffer.c | 7 +++++++ > include/linux/iio/buffer.h | 3 +++ > 2 files changed, 10 insertions(+) > > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c > index 1d950a3e153b..4b1ca6ad86ee 100644 > --- a/drivers/iio/industrialio-buffer.c > +++ b/drivers/iio/industrialio-buffer.c > @@ -1956,6 +1956,13 @@ void iio_buffer_put(struct iio_buffer *buffer) > } > EXPORT_SYMBOL_GPL(iio_buffer_put); > > +void iio_buffer_set_dir(struct iio_buffer *buffer, > + enum iio_buffer_direction dir) > +{ > + buffer->direction = dir; > +} > +EXPORT_SYMBOL_GPL(iio_buffer_set_dir); > + > /** > * iio_device_attach_buffer - Attach a buffer to a IIO device > * @indio_dev: The device the buffer should be attached to > diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h > index 418b1307d3f2..7e70bb5adc01 100644 > --- a/include/linux/iio/buffer.h > +++ b/include/linux/iio/buffer.h > @@ -55,4 +55,7 @@ bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, > int iio_device_attach_buffer(struct iio_dev *indio_dev, > struct iio_buffer *buffer); > > +void iio_buffer_set_dir(struct iio_buffer *buffer, > + enum iio_buffer_direction dir); > + > #endif /* _IIO_BUFFER_GENERIC_H_ */ >