Lines Matching +full:de +full:- +full:active

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2014-2015 Analog Devices Inc.
4 * Author: Lars-Peter Clausen <lars@metafoo.de>
10 #include <linux/dma-mapping.h>
19 #include <linux/iio/buffer-dma.h>
20 #include <linux/iio/buffer-dmaengine.h>
36 struct list_head active; member
54 spin_lock_irqsave(&block->queue->list_lock, flags); in iio_dmaengine_buffer_block_done()
55 list_del(&block->head); in iio_dmaengine_buffer_block_done()
56 spin_unlock_irqrestore(&block->queue->list_lock, flags); in iio_dmaengine_buffer_block_done()
57 block->bytes_used -= result->residue; in iio_dmaengine_buffer_block_done()
65 iio_buffer_to_dmaengine_buffer(&queue->buffer); in iio_dmaengine_buffer_submit_block()
69 block->bytes_used = min(block->size, dmaengine_buffer->max_size); in iio_dmaengine_buffer_submit_block()
70 block->bytes_used = rounddown(block->bytes_used, in iio_dmaengine_buffer_submit_block()
71 dmaengine_buffer->align); in iio_dmaengine_buffer_submit_block()
73 desc = dmaengine_prep_slave_single(dmaengine_buffer->chan, in iio_dmaengine_buffer_submit_block()
74 block->phys_addr, block->bytes_used, DMA_DEV_TO_MEM, in iio_dmaengine_buffer_submit_block()
77 return -ENOMEM; in iio_dmaengine_buffer_submit_block()
79 desc->callback_result = iio_dmaengine_buffer_block_done; in iio_dmaengine_buffer_submit_block()
80 desc->callback_param = block; in iio_dmaengine_buffer_submit_block()
86 spin_lock_irq(&dmaengine_buffer->queue.list_lock); in iio_dmaengine_buffer_submit_block()
87 list_add_tail(&block->head, &dmaengine_buffer->active); in iio_dmaengine_buffer_submit_block()
88 spin_unlock_irq(&dmaengine_buffer->queue.list_lock); in iio_dmaengine_buffer_submit_block()
90 dma_async_issue_pending(dmaengine_buffer->chan); in iio_dmaengine_buffer_submit_block()
98 iio_buffer_to_dmaengine_buffer(&queue->buffer); in iio_dmaengine_buffer_abort()
100 dmaengine_terminate_sync(dmaengine_buffer->chan); in iio_dmaengine_buffer_abort()
101 iio_dma_buffer_block_list_abort(queue, &dmaengine_buffer->active); in iio_dmaengine_buffer_abort()
109 iio_dma_buffer_release(&dmaengine_buffer->queue); in iio_dmaengine_buffer_release()
137 iio_buffer_to_dmaengine_buffer(indio_dev->buffer); in iio_dmaengine_buffer_get_length_align()
139 return sprintf(buf, "%zu\n", dmaengine_buffer->align); in iio_dmaengine_buffer_get_length_align()
151 * iio_dmaengine_buffer_alloc() - Allocate new buffer which uses DMAengine
173 return ERR_PTR(-ENOMEM); in iio_dmaengine_buffer_alloc()
196 INIT_LIST_HEAD(&dmaengine_buffer->active); in iio_dmaengine_buffer_alloc()
197 dmaengine_buffer->chan = chan; in iio_dmaengine_buffer_alloc()
198 dmaengine_buffer->align = width; in iio_dmaengine_buffer_alloc()
199 dmaengine_buffer->max_size = dma_get_max_seg_size(chan->device->dev); in iio_dmaengine_buffer_alloc()
201 iio_dma_buffer_init(&dmaengine_buffer->queue, chan->device->dev, in iio_dmaengine_buffer_alloc()
203 iio_buffer_set_attrs(&dmaengine_buffer->queue.buffer, in iio_dmaengine_buffer_alloc()
206 dmaengine_buffer->queue.buffer.access = &iio_dmaengine_buffer_ops; in iio_dmaengine_buffer_alloc()
208 return &dmaengine_buffer->queue.buffer; in iio_dmaengine_buffer_alloc()
216 * iio_dmaengine_buffer_free() - Free dmaengine buffer
226 iio_dma_buffer_exit(&dmaengine_buffer->queue); in iio_dmaengine_buffer_free()
227 dma_release_channel(dmaengine_buffer->chan); in iio_dmaengine_buffer_free()
238 * devm_iio_dmaengine_buffer_alloc() - Resource-managed iio_dmaengine_buffer_alloc()
246 * The buffer will be automatically de-allocated once the device gets destroyed.
256 return ERR_PTR(-ENOMEM); in devm_iio_dmaengine_buffer_alloc()
271 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");