[PATCH 29/53] staging: comedi: usbdux: tidy up usbdux_ai_stop()

H Hartley Sweeten hsweeten at visionengravers.com
Wed Jul 24 21:17:23 UTC 2013


For aesthetic reasons, pass the comedi_device pointer to this function
instead of the private data pointer. Rename the local variable used
for the private data pointer to the comedi "norm".

Remove the unnecessary sanity check of the private data pointer. This
function can only be called is the private data was allocated during
the attach.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfondation.org>
---
 drivers/staging/comedi/drivers/usbdux.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 0434674..c195ec6 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -270,24 +270,15 @@ static int usbduxsub_unlink_inurbs(struct usbdux_private *usbduxsub_tmp)
 	return err;
 }
 
-/*
- * This will stop a running acquisition operation
- * Is called from within this driver from both the
- * interrupt context and from comedi
- */
-static int usbdux_ai_stop(struct usbdux_private *this_usbduxsub, int do_unlink)
+static int usbdux_ai_stop(struct comedi_device *dev, int do_unlink)
 {
+	struct usbdux_private *devpriv = dev->private;
 	int ret = 0;
 
-	if (!this_usbduxsub)
-		return -EFAULT;
-
-	if (do_unlink) {
-		/* stop aquistion */
-		ret = usbduxsub_unlink_inurbs(this_usbduxsub);
-	}
+	if (do_unlink)
+		ret = usbduxsub_unlink_inurbs(devpriv);
 
-	this_usbduxsub->ai_cmd_running = 0;
+	devpriv->ai_cmd_running = 0;
 
 	return ret;
 }
@@ -310,7 +301,7 @@ static int usbdux_ai_cancel(struct comedi_device *dev,
 	/* prevent other CPUs from submitting new commands just now */
 	down(&this_usbduxsub->sem);
 	/* unlink only if the urb really has been submitted */
-	res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running);
+	res = usbdux_ai_stop(dev, this_usbduxsub->ai_cmd_running);
 	up(&this_usbduxsub->sem);
 	return res;
 }
@@ -346,7 +337,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
 			s->async->events |= COMEDI_CB_ERROR;
 			comedi_event(dev, s);
 			/* stop the transfer w/o unlink */
-			usbdux_ai_stop(devpriv, 0);
+			usbdux_ai_stop(dev, 0);
 		}
 		return;
 
@@ -361,7 +352,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
 			s->async->events |= COMEDI_CB_ERROR;
 			comedi_event(dev, s);
 			/* don't do an unlink here */
-			usbdux_ai_stop(devpriv, 0);
+			usbdux_ai_stop(dev, 0);
 		}
 		return;
 	}
@@ -392,7 +383,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
 		s->async->events |= COMEDI_CB_ERROR;
 		comedi_event(dev, s);
 		/* don't do an unlink here */
-		usbdux_ai_stop(devpriv, 0);
+		usbdux_ai_stop(dev, 0);
 		return;
 	}
 
@@ -410,7 +401,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
 		/* all samples received? */
 		if (devpriv->ai_sample_count < 0) {
 			/* prevent a resubmit next time */
-			usbdux_ai_stop(devpriv, 0);
+			usbdux_ai_stop(dev, 0);
 			/* say comedi that the acquistion is over */
 			s->async->events |= COMEDI_CB_EOA;
 			comedi_event(dev, s);
@@ -430,7 +421,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
 		}
 		if (unlikely(err == 0)) {
 			/* buffer overflow */
-			usbdux_ai_stop(devpriv, 0);
+			usbdux_ai_stop(dev, 0);
 			return;
 		}
 	}
-- 
1.8.3.2



More information about the devel mailing list