summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorJonathan Cameron2017-01-02 20:28:32 +0100
committerJonathan Cameron2017-01-10 20:54:54 +0100
commit2b827ad54111439b919605da90e122ecda88bad6 (patch)
tree2032805699057846a7823fcc890a84e69f3ccb31 /drivers/iio/industrialio-buffer.c
parentiio:buffer.h include pushdown into buffer implementations (diff)
downloadkernel-qcow2-linux-2b827ad54111439b919605da90e122ecda88bad6.tar.gz
kernel-qcow2-linux-2b827ad54111439b919605da90e122ecda88bad6.tar.xz
kernel-qcow2-linux-2b827ad54111439b919605da90e122ecda88bad6.zip
iio:buffer: Push implementation of iio_device_attach_buffer into .c file
This is a precursor to the splitting of buffer.h into parts relevant to buffer implementation vs those for devices using buffers. struct buffer is about to become opaque as far as the header is concerned. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 0067e184c9ae..a04498231f94 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1445,3 +1445,19 @@ void iio_buffer_put(struct iio_buffer *buffer)
kref_put(&buffer->ref, iio_buffer_release);
}
EXPORT_SYMBOL_GPL(iio_buffer_put);
+
+/**
+ * iio_device_attach_buffer - Attach a buffer to a IIO device
+ * @indio_dev: The device the buffer should be attached to
+ * @buffer: The buffer to attach to the device
+ *
+ * This function attaches a buffer to a IIO device. The buffer stays attached to
+ * the device until the device is freed. The function should only be called at
+ * most once per device.
+ */
+void iio_device_attach_buffer(struct iio_dev *indio_dev,
+ struct iio_buffer *buffer)
+{
+ indio_dev->buffer = iio_buffer_get(buffer);
+}
+EXPORT_SYMBOL_GPL(iio_device_attach_buffer);