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)
commitafd055838cfb6f387e8b6d1f884a7ff529524e06
treec9f88e6853d1e0d0e1e519aaf8e96c1ff2bd2b25
parentd375278d666760e195693b57415ba0a125cadd55
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
This page took 0.02483 seconds and 5 git commands to generate.