Skip to content

Commit 65e02d0

Browse files
commodoJonathan Cameron
authored andcommitted
iio: buffer-dmaengine: adjust bytes_used with residue info
A transfer may fall shorter than the bytes in the block. This information is available in the residue from the DMA engine, so we can compute actual `bytes_used` with that by subtracting the residue. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20200826052011.13348-1-lars@metafoo.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent e7b61fc commit 65e02d0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎drivers/iio/buffer/industrialio-buffer-dmaengine.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ static struct dmaengine_buffer *iio_buffer_to_dmaengine_buffer(
4545
return container_of(buffer, struct dmaengine_buffer, queue.buffer);
4646
}
4747

48-
static void iio_dmaengine_buffer_block_done(void *data)
48+
static void iio_dmaengine_buffer_block_done(void *data,
49+
const struct dmaengine_result *result)
4950
{
5051
struct iio_dma_buffer_block *block = data;
5152
unsigned long flags;
5253

5354
spin_lock_irqsave(&block->queue->list_lock, flags);
5455
list_del(&block->head);
5556
spin_unlock_irqrestore(&block->queue->list_lock, flags);
57+
block->bytes_used -= result->residue;
5658
iio_dma_buffer_block_done(block);
5759
}
5860

@@ -74,7 +76,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
7476
if (!desc)
7577
return -ENOMEM;
7678

77-
desc->callback = iio_dmaengine_buffer_block_done;
79+
desc->callback_result = iio_dmaengine_buffer_block_done;
7880
desc->callback_param = block;
7981

8082
cookie = dmaengine_submit(desc);

0 commit comments

Comments
 (0)