staging: comedi: comedi_buf: make comedi_buf_read_samples() always return full samples
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 22 Oct 2014 21:36:42 +0000 (14:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2014 08:01:19 +0000 (16:01 +0800)
commit8de27e7010cbd8c75a4e04a9807adacc7a8d70b2
treec9673022fa6dd0891a58637f1bfc5820c2252be6
parent109bf06e2a88a04607c93d8223e4be0af09ebc8c
staging: comedi: comedi_buf: make comedi_buf_read_samples() always return full samples

A number of drivers currently use comedi_buf_get() to read single samples
from the the async buffer. This works but the drivers have to handle the
COMEDI_CB_BLOCK and COMEDI_CB_EOS events. Converting those drivers to use
comedi_buf_read_samples() moves the handling of those events into the core.

Modify comedi_buf_read_samples() so that the async buffer is checked for
the number of full samples available. Use that to clamp the number of
samples that will be read. This makes sure that only full samples are
read from the async buffer making comedi_buf_read_samples() mimic the
action of comedi_buf_get() with the added benifit of handling the events.

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