staging: comedi: pcl818: fix pcl818_handle_dma() for short DMA transaction
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 12 Jan 2015 17:55:59 +0000 (10:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 22:25:20 +0000 (14:25 -0800)
commit1c53093a1dea755f5ab9598d57b78f9a9444262d
tree406e4856270f9ad4b4b06717dbcf79dc805b4e0d
parent7a37b7a7556fe6b4108ad7cea25a484b87d11ee9
staging: comedi: pcl818: fix pcl818_handle_dma() for short DMA transaction

Currently this function always transfers the full DMA buffer to the comedi
async buffer. When the cmd->stop_src == TRIG_COUNT the last DMA transfer
might be smaller than the buffer size. This results in invalid data being
added to the asunc buffer.

Add a 'size' member to the DMA descriptor and initialize it with the
actual size of the DMA transfer. Use that in pcl818_handle_dma() to
return the proper number of samples. Use the comedi_bytes_to_samples()
helper to convert the byte size to comedi samples. Remove the unnecessary
'bufptr' local variable.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcl818.c