Commit 91891f7c authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbdux: clarify bipolar ai data

Use the comedi_range_is_bipolar() helper instead of checking the
'range' index against a magic number.

Also, use the s->maxdata to calculate the value needed to munge the
value for bipolar data instead of the magic number.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a79b4cdb
......@@ -1002,8 +1002,10 @@ static int usbdux_ai_insn_read(struct comedi_device *dev,
goto ai_read_exit;
val = le16_to_cpu(devpriv->insn_buffer[1]);
if (range <= 1)
val ^= 0x800;
/* bipolar data is two's-complement */
if (comedi_range_is_bipolar(s, range))
val ^= ((s->maxdata + 1) >> 1);
data[i] = val;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment