staging: comedi: das08: clarify sign-magnitude conversion
authorIan Abbott <abbotti@mev.co.uk>
Fri, 5 Jun 2015 17:30:34 +0000 (18:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Jun 2015 00:06:42 +0000 (17:06 -0700)
commit34cce4628b8509dc894735cdc5de8b10db21873a
treeee417940929e15198ae0bcd69828156c8175f170
parent3919c3d5891b079b5d03c03b4df4e3fca9572eca
staging: comedi: das08: clarify sign-magnitude conversion

For DAS08/JR/16 and DAS08/JR/AO-16 boards, the 16-bit analog input
readings are assumed to be in a sign-magnitude format and need
converting to the COMEDI unsigned sample format.  The expressions to do
the conversion look a little messy.  Use a local variable `magnitude` to
make it easier to follow.

Also, there seems to be some discrepancy between the manual for these
boards and the COMEDI code.  The manual implies that 0 is full-scale
negative and 65535 is full-scale positive.  However, the COMEDI code has
used the sign-magnitude conversion for these boards since these two
boards were initially supported by a patch from an external contributor
to the COMEDI project back in 2001.  Assume the code is correct for now,
but add a comment to mention the discrepancy.

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