Commit 147b25a3 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbduxsigma: tidy up usbduxsub_ai_IsocIrq()

Rename the local variables to follow the "norm" for comedi drivers.
The comedi_subdevice for this function is the dev->read_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.
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 f31260f9
...@@ -279,37 +279,29 @@ static int usbdux_ai_cancel(struct comedi_device *dev, ...@@ -279,37 +279,29 @@ static int usbdux_ai_cancel(struct comedi_device *dev,
return 0; return 0;
} }
/* analogue IN - interrupt service routine */
static void usbduxsub_ai_IsocIrq(struct urb *urb) static void usbduxsub_ai_IsocIrq(struct urb *urb)
{ {
int i, err, n; struct comedi_device *dev = urb->context;
struct usbduxsub *this_usbduxsub; struct usbduxsub *devpriv = dev->private;
struct comedi_device *this_comedidev; struct comedi_subdevice *s = dev->read_subdev;
struct comedi_subdevice *s;
int32_t v;
unsigned int dio_state; unsigned int dio_state;
int32_t val;
/* the context variable points to the comedi device */ int ret;
this_comedidev = urb->context; int i;
/* the private structure of the subdevice is struct usbduxsub */
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->inBuffer, memcpy(devpriv->inBuffer, urb->transfer_buffer, SIZEINBUF);
urb->transfer_buffer, SIZEINBUF);
break; break;
case -EILSEQ: case -EILSEQ:
/* error in the ISOchronous data */ /*
/* we don't copy the data into the transfer buffer */ * error in the ISOchronous data
/* and recycle the last data byte */ * we don't copy the data into the transfer buffer
dev_dbg(&urb->dev->dev, * and recycle the last data byte
"comedi%d: usbdux: CRC error in ISO IN stream.\n", */
this_usbduxsub->comedidev->minor); dev_dbg(dev->class_dev,"CRC error in ISO IN stream\n");
break; break;
...@@ -318,110 +310,87 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb) ...@@ -318,110 +310,87 @@ static void usbduxsub_ai_IsocIrq(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 */ usbdux_ai_stop(devpriv, 0); /* w/o unlink */
/* tell this comedi */ /* we are still running a command, tell comedi */
s->async->events |= COMEDI_CB_EOA; s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
s->async->events |= COMEDI_CB_ERROR; comedi_event(dev, s);
comedi_event(this_usbduxsub->comedidev, s);
/* stop the transfer w/o unlink */
usbdux_ai_stop(this_usbduxsub, 0);
} }
return; return;
default: default:
/* a real error on the bus */ /*
/* pass error to comedi if we are really running a command */ * a real error on the bus
if (this_usbduxsub->ai_cmd_running) { * pass error to comedi if we are really running a command
dev_err(&urb->dev->dev, */
"Non-zero urb status received in ai intr " if (devpriv->ai_cmd_running) {
"context: %d\n", urb->status); dev_err(dev->class_dev,
s->async->events |= COMEDI_CB_EOA; "%s: non-zero urb status (%d)\n",
s->async->events |= COMEDI_CB_ERROR; __func__, urb->status);
comedi_event(this_usbduxsub->comedidev, s); usbdux_ai_stop(devpriv, 0); /* w/o unlink */
/* don't do an unlink here */ s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
usbdux_ai_stop(this_usbduxsub, 0); comedi_event(dev, s);
} }
return; return;
} }
/* if (unlikely(!devpriv->ai_cmd_running))
* at this point we are reasonably sure that nothing dodgy has happened
* are we running a command?
*/
if (unlikely((!(this_usbduxsub->ai_cmd_running)))) {
/*
* not running a command, do not continue execution if no
* asynchronous command is running in particular not resubmit
*/
return; return;
}
urb->dev = this_usbduxsub->usbdev; urb->dev = devpriv->usbdev;
/* resubmit the urb */ ret = usb_submit_urb(urb, GFP_ATOMIC);
err = usb_submit_urb(urb, GFP_ATOMIC); if (unlikely(ret < 0)) {
if (unlikely(err < 0)) { dev_err(dev->class_dev, "%s: urb resubmit failed (%d)\n",
dev_err(&urb->dev->dev, __func__, ret);
"comedi_: urb resubmit failed in int-context!" if (ret == -EL2NSYNC)
"err=%d\n", dev_err(dev->class_dev,
err); "buggy USB host controller or bug in IRQ handler\n");
if (err == -EL2NSYNC) usbdux_ai_stop(devpriv, 0); /* w/o unlink */
dev_err(&urb->dev->dev, s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR);
"buggy USB host controller or bug in IRQ " comedi_event(dev, s);
"handler!\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_ai_stop(this_usbduxsub, 0);
return; return;
} }
/* get the state of the dio pins to allow external trigger */ /* get the state of the dio pins to allow external trigger */
dio_state = be32_to_cpu(this_usbduxsub->inBuffer[0]); dio_state = be32_to_cpu(devpriv->inBuffer[0]);
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 */ if (!devpriv->ai_continuous) {
if (!(this_usbduxsub->ai_continuous)) {
/* not continuous, fixed number of samples */ /* not continuous, fixed number of samples */
this_usbduxsub->ai_sample_count--; devpriv->ai_sample_count--;
/* all samples received? */ if (devpriv->ai_sample_count < 0) {
if (this_usbduxsub->ai_sample_count < 0) { usbdux_ai_stop(devpriv, 0); /* w/o unlink */
/* prevent a resubmit next time */ /* acquistion is over, tell comedi */
usbdux_ai_stop(this_usbduxsub, 0);
/* 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;
} }
} }
/* 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; for (i = 0; i < s->async->cmd.chanlist_len; i++) {
for (i = 0; i < n; i++) {
/* transfer data, note first byte is the DIO state */ /* transfer data, note first byte is the DIO state */
v = be32_to_cpu(this_usbduxsub->inBuffer[i+1]); val = be32_to_cpu(devpriv->inBuffer[i+1]);
/* strip status byte */ val &= 0x00ffffff; /* strip status byte */
v = v & 0x00ffffff; val ^= 0x00800000; /* convert to unsigned */
/* convert to unsigned */
v = v ^ 0x00800000; ret = cfc_write_array_to_buffer(s, &val, sizeof(uint32_t));
/* write the byte to the buffer */ if (unlikely(ret == 0)) {
err = cfc_write_array_to_buffer(s, &v, sizeof(uint32_t));
if (unlikely(err == 0)) {
/* buffer overflow */ /* buffer overflow */
usbdux_ai_stop(this_usbduxsub, 0); usbdux_ai_stop(devpriv, 0); /* w/o unlink */
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 void usbdux_ao_stop(struct usbduxsub *devpriv, int do_unlink) static void usbdux_ao_stop(struct usbduxsub *devpriv, int do_unlink)
......
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