staging: comedi: das16: fix DMA size for short transfers
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 26 Jan 2015 23:17:20 +0000 (16:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jan 2015 19:14:04 +0000 (11:14 -0800)
commit1dc6e72903f6dbefd79ea2e9ce9c9e536e4e695b
treedbcd43b33090adc595dafcbde16fac26bd048fc8
parent42c44682a59a6ea38a301c20a4ec807c6fabdd02
staging: comedi: das16: fix DMA size for short transfers

Currently this driver alwasy programs the DMA transfer to be the allocated
size of the DMA buffer. When the async command 'stop_src' is TRIG_COUNT its
possible (likely) for the last transfer to be less than the buffer size.

Introduce a helper function, das16_ai_setup_dma(), to calculate the actual
size of the DMA transfer based on the number of samples remaining and the
number of unread samples.

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/das16.c