On Wed, Aug 26, 2020 at 8:22 AM Lars-Peter Clausen <lars@xxxxxxxxxx> wrote: > > From: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> > > 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. > This was in my pipeline as well [obviously]. Thanks :) > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> > Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx> > --- > drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c > index 6dedf12b69a4..5789bda0745b 100644 > --- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c > +++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c > @@ -45,7 +45,8 @@ static struct dmaengine_buffer *iio_buffer_to_dmaengine_buffer( > return container_of(buffer, struct dmaengine_buffer, queue.buffer); > } > > -static void iio_dmaengine_buffer_block_done(void *data) > +static void iio_dmaengine_buffer_block_done(void *data, > + const struct dmaengine_result *result) > { > struct iio_dma_buffer_block *block = data; > unsigned long flags; > @@ -53,6 +54,7 @@ static void iio_dmaengine_buffer_block_done(void *data) > spin_lock_irqsave(&block->queue->list_lock, flags); > list_del(&block->head); > spin_unlock_irqrestore(&block->queue->list_lock, flags); > + block->bytes_used -= result->residue; > iio_dma_buffer_block_done(block); > } > > @@ -74,7 +76,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, > if (!desc) > return -ENOMEM; > > - desc->callback = iio_dmaengine_buffer_block_done; > + desc->callback_result = iio_dmaengine_buffer_block_done; > desc->callback_param = block; > > cookie = dmaengine_submit(desc); > -- > 2.20.1 >