aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-03-28 12:20:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-23 19:20:15 -0400
commit2704f807f9498054b8153002bafa3e818079e9a5 (patch)
treea4cca20ab339fcc3832a9c864bf02fd57ae2f2e7
parent8b425aa193439a2b60a988a9230f1de753e36902 (diff)
staging: comedi: usbdux: bug fix for accessing 'ao_chanlist' in private data
In usbdux_ao_cmd(), the channels for the command are transfered from the cmd->chanlist and stored in the private data 'ao_chanlist'. The channel numbers are bit-shifted when stored so that they become the "command" that is transfered to the device. The channel to command conversion results in the 'ao_chanlist' having these values for the channels: channel 0 -> ao_chanlist = 0x00 channel 1 -> ao_chanlist = 0x40 channel 2 -> ao_chanlist = 0x80 channel 3 -> ao_chanlist = 0xc0 The problem is, the usbduxsub_ao_isoc_irq() function uses the 'chan' value from 'ao_chanlist' to access the 'ao_readback' array in the private data. So instead of accessing the array as 0, 1, 2, 3, it accesses it as 0x00, 0x40, 0x80, 0xc0. Fix this by storing the raw channel number in 'ao_chanlist' and doing the bit-shift when creating the command. Fixes: a998a3db530bff80 "staging: comedi: usbdux: cleanup the private data 'outBuffer'" Cc: stable <stable@vger.kernel.org> # 3.12 Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Acked-by: Bernd Porr <mail@berndporr.me.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 71db683098d6..b59af0303581 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -493,7 +493,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
493 /* pointer to the DA */ 493 /* pointer to the DA */
494 *datap++ = val & 0xff; 494 *datap++ = val & 0xff;
495 *datap++ = (val >> 8) & 0xff; 495 *datap++ = (val >> 8) & 0xff;
496 *datap++ = chan; 496 *datap++ = chan << 6;
497 devpriv->ao_readback[chan] = val; 497 devpriv->ao_readback[chan] = val;
498 498
499 s->async->events |= COMEDI_CB_BLOCK; 499 s->async->events |= COMEDI_CB_BLOCK;
@@ -1040,11 +1040,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
1040 /* set current channel of the running acquisition to zero */ 1040 /* set current channel of the running acquisition to zero */
1041 s->async->cur_chan = 0; 1041 s->async->cur_chan = 0;
1042 1042
1043 for (i = 0; i < cmd->chanlist_len; ++i) { 1043 for (i = 0; i < cmd->chanlist_len; ++i)
1044 unsigned int chan = CR_CHAN(cmd->chanlist[i]); 1044 devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
1045
1046 devpriv->ao_chanlist[i] = chan << 6;
1047 }
1048 1045
1049 /* we count in steps of 1ms (125us) */ 1046 /* we count in steps of 1ms (125us) */
1050 /* 125us mode not used yet */ 1047 /* 125us mode not used yet */