Skip to content

Commit

Permalink
staging: comedi: usbdux: clarify bipolar ai data
Browse files Browse the repository at this point in the history
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 26, 2013
1 parent a79b4cd commit 91891f7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/staging/comedi/drivers/usbdux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 91891f7

Please sign in to comment.