Commit 0a9502f2 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbdux: tidy up usbduxsub_ai_isoc_irq()

Rename the local variables to the comedi "norm".

The comedi_subdevice in this function is actually the dev->read_subdev
that was initialized in the attach. Use that instead of accessing the
dev->subdevices array directly.

Use dev->class_dev as the device for all dev_printk() messages.

Instead of using the 'comedidev' back pointer in the private data, use
the comedi_device 'dev' that we already have.
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 cc84f4f9
...@@ -357,33 +357,22 @@ static int usbdux_ai_cancel(struct comedi_device *dev, ...@@ -357,33 +357,22 @@ static int usbdux_ai_cancel(struct comedi_device *dev,
/* analogue IN - interrupt service routine */ /* analogue IN - interrupt service routine */
static void usbduxsub_ai_isoc_irq(struct urb *urb) static void usbduxsub_ai_isoc_irq(struct urb *urb)
{ {
struct comedi_device *dev = urb->context;
struct comedi_subdevice *s = dev->read_subdev;
struct usbdux_private *devpriv = dev->private;
int i, err, n; int i, err, n;
struct usbdux_private *this_usbduxsub;
struct comedi_device *this_comedidev;
struct comedi_subdevice *s;
/* the context variable points to the subdevice */
this_comedidev = urb->context;
/* the private structure of the subdevice is struct usbdux_private */
this_usbduxsub = this_comedidev->private;
/* subdevice which is the AD converter */
s = &this_comedidev->subdevices[SUBDEV_AD];
/* first we test if something unusual has just happened */ /* first we test if something unusual has just happened */
switch (urb->status) { switch (urb->status) {
case 0: case 0:
/* copy the result in the transfer buffer */ /* copy the result in the transfer buffer */
memcpy(this_usbduxsub->in_buffer, memcpy(devpriv->in_buffer, urb->transfer_buffer, SIZEINBUF);
urb->transfer_buffer, SIZEINBUF);
break; break;
case -EILSEQ: case -EILSEQ:
/* error in the ISOchronous data */ /* error in the ISOchronous data */
/* we don't copy the data into the transfer buffer */ /* we don't copy the data into the transfer buffer */
/* and recycle the last data byte */ /* and recycle the last data byte */
dev_dbg(&urb->dev->dev, dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n");
"comedi%d: usbdux: CRC error in ISO IN stream.\n",
this_usbduxsub->comedidev->minor);
break; break;
case -ECONNRESET: case -ECONNRESET:
...@@ -391,29 +380,27 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) ...@@ -391,29 +380,27 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
case -ESHUTDOWN: case -ESHUTDOWN:
case -ECONNABORTED: case -ECONNABORTED:
/* happens after an unlink command */ /* happens after an unlink command */
if (this_usbduxsub->ai_cmd_running) { if (devpriv->ai_cmd_running) {
/* we are still running a command */
/* tell this comedi */
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR; s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
/* stop the transfer w/o unlink */ /* stop the transfer w/o unlink */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0);
} }
return; return;
default: default:
/* a real error on the bus */ /* a real error on the bus */
/* pass error to comedi if we are really running a command */ /* pass error to comedi if we are really running a command */
if (this_usbduxsub->ai_cmd_running) { if (devpriv->ai_cmd_running) {
dev_err(&urb->dev->dev, dev_err(dev->class_dev,
"Non-zero urb status received in ai intr " "Non-zero urb status received in ai intr context: %d\n",
"context: %d\n", urb->status); urb->status);
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR; s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
/* don't do an unlink here */ /* don't do an unlink here */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0);
} }
return; return;
} }
...@@ -422,7 +409,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) ...@@ -422,7 +409,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
* at this point we are reasonably sure that nothing dodgy has happened * at this point we are reasonably sure that nothing dodgy has happened
* are we running a command? * are we running a command?
*/ */
if (unlikely((!(this_usbduxsub->ai_cmd_running)))) { if (unlikely(!devpriv->ai_cmd_running)) {
/* /*
* not running a command, do not continue execution if no * not running a command, do not continue execution if no
* asynchronous command is running in particular not resubmit * asynchronous command is running in particular not resubmit
...@@ -430,44 +417,42 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) ...@@ -430,44 +417,42 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
return; return;
} }
urb->dev = this_usbduxsub->usbdev; urb->dev = devpriv->usbdev;
/* resubmit the urb */ /* resubmit the urb */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
if (unlikely(err < 0)) { if (unlikely(err < 0)) {
dev_err(&urb->dev->dev, dev_err(dev->class_dev,
"comedi_: urb resubmit failed in int-context! err=%d\n", "urb resubmit failed in int-context! err=%d\n", err);
err);
if (err == -EL2NSYNC) if (err == -EL2NSYNC)
dev_err(&urb->dev->dev, dev_err(dev->class_dev,
"buggy USB host controller or bug in IRQ " "buggy USB host controller or bug in IRQ handler!\n");
"handler!\n");
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR; s->async->events |= COMEDI_CB_ERROR;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
/* don't do an unlink here */ /* don't do an unlink here */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0);
return; return;
} }
this_usbduxsub->ai_counter--; devpriv->ai_counter--;
if (likely(this_usbduxsub->ai_counter > 0)) if (likely(devpriv->ai_counter > 0))
return; return;
/* timer zero, transfer measurements to comedi */ /* timer zero, transfer measurements to comedi */
this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; devpriv->ai_counter = devpriv->ai_timer;
/* test, if we transmit only a fixed number of samples */ /* test, if we transmit only a fixed number of samples */
if (!(this_usbduxsub->ai_continous)) { if (!devpriv->ai_continous) {
/* not continuous, fixed number of samples */ /* not continuous, fixed number of samples */
this_usbduxsub->ai_sample_count--; devpriv->ai_sample_count--;
/* all samples received? */ /* all samples received? */
if (this_usbduxsub->ai_sample_count < 0) { if (devpriv->ai_sample_count < 0) {
/* prevent a resubmit next time */ /* prevent a resubmit next time */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0);
/* say comedi that the acquistion is over */ /* say comedi that the acquistion is over */
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
return; return;
} }
} }
...@@ -476,23 +461,21 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) ...@@ -476,23 +461,21 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
/* transfer data */ /* transfer data */
if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) {
err = comedi_buf_put err = comedi_buf_put(s->async,
(s->async, le16_to_cpu(devpriv->in_buffer[i]) ^ 0x800);
le16_to_cpu(this_usbduxsub->in_buffer[i]) ^ 0x800);
} else { } else {
err = comedi_buf_put err = comedi_buf_put(s->async,
(s->async, le16_to_cpu(devpriv->in_buffer[i]));
le16_to_cpu(this_usbduxsub->in_buffer[i]));
} }
if (unlikely(err == 0)) { if (unlikely(err == 0)) {
/* buffer overflow */ /* buffer overflow */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0);
return; return;
} }
} }
/* tell comedi that data is there */ /* tell comedi that data is there */
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
comedi_event(this_usbduxsub->comedidev, s); comedi_event(dev, s);
} }
static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp)
......
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