[RFC PATCH 10/39] staging: comedi: usbduxfast: tidy up usbduxfastsub_ai_Irq()
H Hartley Sweeten
hsweeten at visionengravers.com
Wed May 1 22:21:04 UTC 2013
Rename the CamelCase function,
Rename some of the local variables to the normal names used in
comedi drivers. Add a local variable for the comedi_async *.
Remove the sanity checking. The urb that causes this function to
be called can only be submitted if the sanity checks already
passed.
Change the way the comedi_subdevice is fetched. The attach function
sets the dev->read_subev pointer to the correct subdevice. Use that
instead of accessing the dev->subdevices array directly.
Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfonudation.org>
---
drivers/staging/comedi/drivers/usbduxfast.c | 57 ++++++++++-------------------
1 file changed, 19 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 529fcde..b3be70a 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -289,30 +289,14 @@ static int usbduxfast_ai_cancel(struct comedi_device *dev,
* analogue IN
* interrupt service routine
*/
-static void usbduxfastsub_ai_Irq(struct urb *urb)
+static void usbduxfast_ai_interrupt(struct urb *urb)
{
+ struct comedi_device *dev = urb->context;
+ struct comedi_subdevice *s = dev->read_subdev;
+ struct comedi_async *async = s->async;
+ struct usbduxfast_private *devpriv = dev->private;
int n, err;
- struct usbduxfast_private *devpriv;
- struct comedi_device *this_comedidev;
- struct comedi_subdevice *s;
- /* sanity checks - is the urb there? */
- if (!urb) {
- pr_err("ao int-handler called with urb=NULL!\n");
- return;
- }
- /* the context variable points to the subdevice */
- this_comedidev = urb->context;
- if (!this_comedidev) {
- pr_err("urb context is a NULL pointer!\n");
- return;
- }
- /* the private structure of the subdevice is usbduxfast_private */
- devpriv = this_comedidev->private;
- if (!devpriv) {
- pr_err("private of comedi subdev is a NULL pointer!\n");
- return;
- }
/* are we running a command? */
if (unlikely(!devpriv->ai_cmd_running)) {
/*
@@ -327,8 +311,6 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
/* no comedi device there */
return;
}
- /* subdevice which is the AD converter */
- s = &this_comedidev->subdevices[SUBDEV_AD];
/* first we test if something unusual has just happened */
switch (urb->status) {
@@ -344,9 +326,9 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
case -ESHUTDOWN:
case -ECONNABORTED:
/* tell this comedi */
- s->async->events |= COMEDI_CB_EOA;
- s->async->events |= COMEDI_CB_ERROR;
- comedi_event(devpriv->comedidev, s);
+ async->events |= COMEDI_CB_EOA;
+ async->events |= COMEDI_CB_ERROR;
+ comedi_event(dev, s);
/* stop the transfer w/o unlink */
usbduxfast_ai_stop(devpriv, 0);
return;
@@ -354,9 +336,9 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
default:
pr_err("non-zero urb status received in ai intr context: %d\n",
urb->status);
- s->async->events |= COMEDI_CB_EOA;
- s->async->events |= COMEDI_CB_ERROR;
- comedi_event(devpriv->comedidev, s);
+ async->events |= COMEDI_CB_EOA;
+ async->events |= COMEDI_CB_ERROR;
+ comedi_event(dev, s);
usbduxfast_ai_stop(devpriv, 0);
return;
}
@@ -376,8 +358,8 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
* sizeof(uint16_t));
usbduxfast_ai_stop(devpriv, 0);
/* tell comedi that the acquistion is over */
- s->async->events |= COMEDI_CB_EOA;
- comedi_event(devpriv->comedidev, s);
+ async->events |= COMEDI_CB_EOA;
+ comedi_event(dev, s);
return;
}
devpriv->ai_sample_count -= n;
@@ -392,8 +374,7 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
}
/* tell comedi that data is there */
- comedi_event(devpriv->comedidev, s);
-
+ comedi_event(dev, s);
} else {
/* ignore this packet */
devpriv->ignore--;
@@ -409,9 +390,9 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
if (err < 0) {
dev_err(&urb->dev->dev,
"urb resubm failed: %d", err);
- s->async->events |= COMEDI_CB_EOA;
- s->async->events |= COMEDI_CB_ERROR;
- comedi_event(devpriv->comedidev, s);
+ async->events |= COMEDI_CB_EOA;
+ async->events |= COMEDI_CB_ERROR;
+ comedi_event(dev, s);
usbduxfast_ai_stop(devpriv, 0);
}
}
@@ -505,8 +486,8 @@ static int usbduxfastsub_submit_InURBs(struct usbduxfast_private *devpriv)
usb_fill_bulk_urb(devpriv->urbIn, devpriv->usb,
usb_rcvbulkpipe(devpriv->usb, BULKINEP),
- devpriv->transfer_buffer,
- SIZEINBUF, usbduxfastsub_ai_Irq, devpriv->comedidev);
+ devpriv->transfer_buffer, SIZEINBUF,
+ usbduxfast_ai_interrupt, devpriv->comedidev);
ret = usb_submit_urb(devpriv->urbIn, GFP_ATOMIC);
if (ret) {
--
1.8.1.4
More information about the devel
mailing list