From: Nuno Sa <nuno.sa@xxxxxxxxxx> Add an helper function to set the direction. This is preliminary change and will be useful for IIO backends that provide output buffers. Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx> --- drivers/iio/industrialio-buffer.c | 12 ++++++++++++ include/linux/iio/buffer.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index b581a7e80566..504e5a96bd90 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1982,6 +1982,18 @@ void iio_buffer_put(struct iio_buffer *buffer) } EXPORT_SYMBOL_GPL(iio_buffer_put); +/** + * iio_buffer_set_dir() - Set the buffer direction + * @buffer: The buffer to set the direction + * @direction: The direction + */ +void iio_buffer_set_dir(struct iio_buffer *buffer, + enum iio_buffer_direction direction) +{ + buffer->direction = direction; +} +EXPORT_SYMBOL(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..aee52b834443 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 direction); + #endif /* _IIO_BUFFER_GENERIC_H_ */ -- 2.43.0