]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: das1800: fix analog input sample munging
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 8 Apr 2016 17:14:59 +0000 (10:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Apr 2016 05:12:06 +0000 (22:12 -0700)
commit343341a07baf0b7adcea996756b439bb79967026
treec9f88e6853d1e0d0e1e519aaf8e96c1ff2bd2b25
parenta5cc6f6ff4825adb285c5098a718f328cc7282cb
staging: comedi: das1800: fix analog input sample munging

The analog input samples are 2's complement when the inputs are configured
for bipolar ranges and offset binary when they are unipolar ranges. For
bipolar ranges the sample needs to be munged to the offset binary format
that comedi uses.

The (*insn_read) does the munging correctly but the async command support
incorrectly munges the data for both bipolar and unipolar ranges when
reading the remaining samples from the fifo in das1800_handle_fifo_not_empty().

Add a (*munge) function to the analog input subdevice so that the samples
are correctly munged when they are added to the async buffer by
comedi_buf_write_samples(). Add a flag to the private data and set it in
the (*do_cmd) so that the munging is only done for bipolar ranges.

Clarify the code by using the core helper functions to check the range and
do the munging.

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