diff options
Diffstat (limited to 'drivers/iio/buffer')
-rw-r--r-- | drivers/iio/buffer/industrialio-buffer-dma.c | 2 | ||||
-rw-r--r-- | drivers/iio/buffer/industrialio-buffer-dmaengine.c | 30 | ||||
-rw-r--r-- | drivers/iio/buffer/kfifo_buf.c | 5 |
3 files changed, 31 insertions, 6 deletions
diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index 90cf6e586b10..a74bd9c0587c 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -476,7 +476,7 @@ static struct iio_dma_buffer_block *iio_dma_buffer_dequeue( * @n: Number of bytes to read * @user_buffer: Userspace buffer to copy the data to * - * Should be used as the read_first_n callback for iio_buffer_access_ops + * Should be used as the read callback for iio_buffer_access_ops * struct for DMA buffers. */ int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n, diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c index bea4a75e92f1..b129693af0fd 100644 --- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c +++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c @@ -10,8 +10,10 @@ #include <linux/dma-mapping.h> #include <linux/spinlock.h> #include <linux/err.h> +#include <linux/module.h> #include <linux/iio/iio.h> +#include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> @@ -107,7 +109,7 @@ static void iio_dmaengine_buffer_release(struct iio_buffer *buf) } static const struct iio_buffer_access_funcs iio_dmaengine_buffer_ops = { - .read_first_n = iio_dma_buffer_read, + .read = iio_dma_buffer_read, .set_bytes_per_datum = iio_dma_buffer_set_bytes_per_datum, .set_length = iio_dma_buffer_set_length, .request_update = iio_dma_buffer_request_update, @@ -125,6 +127,24 @@ static const struct iio_dma_buffer_ops iio_dmaengine_default_ops = { .abort = iio_dmaengine_buffer_abort, }; +static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct dmaengine_buffer *dmaengine_buffer = + iio_buffer_to_dmaengine_buffer(indio_dev->buffer); + + return sprintf(buf, "%u\n", dmaengine_buffer->align); +} + +static IIO_DEVICE_ATTR(length_align_bytes, 0444, + iio_dmaengine_buffer_get_length_align, NULL, 0); + +static const struct attribute *iio_dmaengine_buffer_attrs[] = { + &iio_dev_attr_length_align_bytes.dev_attr.attr, + NULL, +}; + /** * iio_dmaengine_buffer_alloc() - Allocate new buffer which uses DMAengine * @dev: Parent device for the buffer @@ -150,7 +170,7 @@ struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, if (!dmaengine_buffer) return ERR_PTR(-ENOMEM); - chan = dma_request_slave_channel_reason(dev, channel); + chan = dma_request_chan(dev, channel); if (IS_ERR(chan)) { ret = PTR_ERR(chan); goto err_free; @@ -178,6 +198,8 @@ struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, iio_dma_buffer_init(&dmaengine_buffer->queue, chan->device->dev, &iio_dmaengine_default_ops); + iio_buffer_set_attrs(&dmaengine_buffer->queue.buffer, + iio_dmaengine_buffer_attrs); dmaengine_buffer->queue.buffer.access = &iio_dmaengine_buffer_ops; @@ -206,3 +228,7 @@ void iio_dmaengine_buffer_free(struct iio_buffer *buffer) iio_buffer_put(buffer); } EXPORT_SYMBOL_GPL(iio_dmaengine_buffer_free); + +MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); +MODULE_DESCRIPTION("DMA buffer for the IIO framework"); +MODULE_LICENSE("GPL"); diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c index e78fc0834e6b..3150f8ab984b 100644 --- a/drivers/iio/buffer/kfifo_buf.c +++ b/drivers/iio/buffer/kfifo_buf.c @@ -98,8 +98,7 @@ static int iio_store_to_kfifo(struct iio_buffer *r, return 0; } -static int iio_read_first_n_kfifo(struct iio_buffer *r, - size_t n, char __user *buf) +static int iio_read_kfifo(struct iio_buffer *r, size_t n, char __user *buf) { int ret, copied; struct iio_kfifo *kf = iio_to_kfifo(r); @@ -141,7 +140,7 @@ static void iio_kfifo_buffer_release(struct iio_buffer *buffer) static const struct iio_buffer_access_funcs kfifo_access_funcs = { .store_to = &iio_store_to_kfifo, - .read_first_n = &iio_read_first_n_kfifo, + .read = &iio_read_kfifo, .data_available = iio_kfifo_buf_data_available, .request_update = &iio_request_update_kfifo, .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, |