Commit 7acf26ed authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbdux: clarify bipolar ai data in usbduxsub_ai_isoc_irq()

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 1731a826
...@@ -363,14 +363,15 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) ...@@ -363,14 +363,15 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
/* get the data from the USB bus and hand it over to comedi */ /* get the data from the USB bus and hand it over to comedi */
n = s->async->cmd.chanlist_len; n = s->async->cmd.chanlist_len;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
unsigned int range = CR_RANGE(s->async->cmd.chanlist[i]);
int16_t val = le16_to_cpu(devpriv->in_buffer[i]);
/* bipolar data is two's-complement */
if (comedi_range_is_bipolar(s, range))
val ^= ((s->maxdata + 1) >> 1);
/* transfer data */ /* transfer data */
if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { err = comedi_buf_put(s->async, val);
err = comedi_buf_put(s->async,
le16_to_cpu(devpriv->in_buffer[i]) ^ 0x800);
} else {
err = comedi_buf_put(s->async,
le16_to_cpu(devpriv->in_buffer[i]));
}
if (unlikely(err == 0)) { if (unlikely(err == 0)) {
/* buffer overflow */ /* buffer overflow */
usbdux_ai_stop(dev, 0); usbdux_ai_stop(dev, 0);
......
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