Commit 641b78f3 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbduxsigma: tidy up usbduxsub_ao_IsocIrq()

Rename the local variables to follow the "norm" for comedi drivers.
The comedi_subdevice for this function is the dev->write_subdev that
was initialized during the (*auto_attach), use that instead of
directly accessing the comedi_device subdevices array.

Use dev->class_dev for any dev_{level} messages.

Remove the extra check of 'ao_cmd_running' before submitting the urb.
This flag was previously checked and if the command is aborted due to
an usbdux_ao_stop() before reaching this point the function will exit.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 147b25a3
...@@ -422,18 +422,13 @@ static int usbdux_ao_cancel(struct comedi_device *dev, ...@@ -422,18 +422,13 @@ static int usbdux_ao_cancel(struct comedi_device *dev,
static void usbduxsub_ao_IsocIrq(struct urb *urb) static void usbduxsub_ao_IsocIrq(struct urb *urb)
{ {
int i, ret; struct comedi_device *dev = urb->context;
struct usbduxsub *devpriv = dev->private;
struct comedi_subdevice *s = dev->write_subdev;
uint8_t *datap; uint8_t *datap;
struct usbduxsub *this_usbduxsub; int len;
struct comedi_device *this_comedidev; int ret;
struct comedi_subdevice *s; int i;
/* the context variable points to the subdevice */
this_comedidev = urb->context;
/* the private structure of the subdevice is struct usbduxsub */
this_usbduxsub = this_comedidev->private;
s = &this_comedidev->subdevices[SUBDEV_DA];
switch (urb->status) { switch (urb->status) {
case 0: case 0:
...@@ -444,112 +439,93 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb) ...@@ -444,112 +439,93 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
case -ECONNABORTED: case -ECONNABORTED:
/* after an unlink command, unplug, ... etc */ /* happens after an unlink command */
/* no unlink needed here. Already shutting down. */ if (devpriv->ao_cmd_running) {
if (this_usbduxsub->ao_cmd_running) { usbdux_ao_stop(devpriv, 0); /* w/o unlink */
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(devpriv->comedidev, s);
usbdux_ao_stop(this_usbduxsub, 0);
} }
return; return;
default: default:
/* a real error */ /* a real error */
if (this_usbduxsub->ao_cmd_running) { if (devpriv->ao_cmd_running) {
dev_err(&urb->dev->dev, dev_err(dev->class_dev,
"comedi_: Non-zero urb status received in ao " "%s: non-zero urb status (%d)\n",
"intr context: %d\n", urb->status); __func__, urb->status);
s->async->events |= COMEDI_CB_ERROR; usbdux_ao_stop(devpriv, 0); /* w/o unlink */
s->async->events |= COMEDI_CB_EOA; s->async->events |= (COMEDI_CB_ERROR | COMEDI_CB_EOA);
comedi_event(this_usbduxsub->comedidev, s); comedi_event(devpriv->comedidev, s);
/* we do an unlink if we are in the high speed mode */
usbdux_ao_stop(this_usbduxsub, 0);
} }
return; return;
} }
/* are we actually running? */ if (!devpriv->ao_cmd_running)
if (!(this_usbduxsub->ao_cmd_running))
return; return;
/* normal operation: executing a command in this subdevice */ devpriv->ao_counter--;
this_usbduxsub->ao_counter--; if ((int)devpriv->ao_counter <= 0) {
if ((int)this_usbduxsub->ao_counter <= 0) { /* timer zero, transfer from comedi */
/* timer zero */ devpriv->ao_counter = devpriv->ao_timer;
this_usbduxsub->ao_counter = this_usbduxsub->ao_timer;
if (!devpriv->ao_continuous) {
/* handle non continuous acquisition */ /* not continuous, fixed number of samples */
if (!(this_usbduxsub->ao_continuous)) { devpriv->ao_sample_count--;
/* fixed number of samples */ if (devpriv->ao_sample_count < 0) {
this_usbduxsub->ao_sample_count--; usbdux_ao_stop(devpriv, 0); /* w/o unlink */
if (this_usbduxsub->ao_sample_count < 0) { /* acquistion is over, tell comedi */
/* all samples transmitted */
usbdux_ao_stop(this_usbduxsub, 0);
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(devpriv->comedidev, s);
/* no resubmit of the urb */
return; return;
} }
} }
/* transmit data to the USB bus */ /* transmit data to the USB bus */
((uint8_t *) (urb->transfer_buffer))[0] = datap = urb->transfer_buffer;
s->async->cmd.chanlist_len; len = s->async->cmd.chanlist_len;
for (i = 0; i < s->async->cmd.chanlist_len; i++) { *datap++ = len;
short temp; for (i = 0; i < len; i++) {
short val;
if (i >= NUMOUTCHANNELS) if (i >= NUMOUTCHANNELS)
break; break;
/* pointer to the DA */ ret = comedi_buf_get(s->async, &val);
datap =
(&(((uint8_t *) urb->transfer_buffer)[i * 2 + 1]));
/* get the data from comedi */
ret = comedi_buf_get(s->async, &temp);
datap[0] = temp;
datap[1] = this_usbduxsub->dac_commands[i];
/* printk("data[0]=%x, data[1]=%x, data[2]=%x\n", */
/* datap[0],datap[1],datap[2]); */
if (ret < 0) { if (ret < 0) {
dev_err(&urb->dev->dev, dev_err(dev->class_dev, "buffer underflow\n");
"comedi: buffer underflow\n"); s->async->events |= (COMEDI_CB_EOA |
s->async->events |= COMEDI_CB_EOA; COMEDI_CB_OVERFLOW);
s->async->events |= COMEDI_CB_OVERFLOW;
} }
/* transmit data to comedi */ *datap++ = val;
*datap++ = devpriv->dac_commands[i];
s->async->events |= COMEDI_CB_BLOCK; s->async->events |= COMEDI_CB_BLOCK;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
} }
} }
urb->transfer_buffer_length = SIZEOUTBUF; urb->transfer_buffer_length = SIZEOUTBUF;
urb->dev = this_usbduxsub->usbdev; urb->dev = devpriv->usbdev;
urb->status = 0; urb->status = 0;
if (this_usbduxsub->ao_cmd_running) { if (devpriv->high_speed)
if (this_usbduxsub->high_speed) { urb->interval = 8; /* uframes */
/* uframes */ else
urb->interval = 8; urb->interval = 1; /* frames */
} else { urb->number_of_packets = 1;
/* frames */ urb->iso_frame_desc[0].offset = 0;
urb->interval = 1; urb->iso_frame_desc[0].length = SIZEOUTBUF;
} urb->iso_frame_desc[0].status = 0;
urb->number_of_packets = 1; ret = usb_submit_urb(urb, GFP_ATOMIC);
urb->iso_frame_desc[0].offset = 0; if (ret < 0) {
urb->iso_frame_desc[0].length = SIZEOUTBUF; dev_err(dev->class_dev,
urb->iso_frame_desc[0].status = 0; "%s: urb resubmit failed (%d)\n",
ret = usb_submit_urb(urb, GFP_ATOMIC); __func__, ret);
if (ret < 0) { if (ret == EL2NSYNC)
dev_err(&urb->dev->dev, dev_err(dev->class_dev,
"comedi_: ao urb resubm failed in int-cont. " "buggy USB host controller or bug in IRQ handler\n");
"ret=%d", ret); usbdux_ao_stop(devpriv, 0); /* w/o unlink */
if (ret == EL2NSYNC) s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
dev_err(&urb->dev->dev, comedi_event(dev, s);
"buggy USB host controller or bug in "
"IRQ handling!\n");
s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s);
/* don't do an unlink here */
usbdux_ao_stop(this_usbduxsub, 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