[PATCH 31/53] staging: comedi: usbdux: tidy up usbdux_ao_stop()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbdux.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index edee148..1f67509 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -436,20 +436,15 @@ static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp)
 	return err;
 }
 
-/* This will cancel a running acquisition operation
- * in any context.
- */
-static int usbdux_ao_stop(struct usbdux_private *this_usbduxsub, int do_unlink)
+static int usbdux_ao_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)
-		ret = usbduxsub_unlink_outurbs(this_usbduxsub);
+		ret = usbduxsub_unlink_outurbs(devpriv);
 
-	this_usbduxsub->ao_cmd_running = 0;
+	devpriv->ao_cmd_running = 0;
 
 	return ret;
 }
@@ -467,7 +462,7 @@ static int usbdux_ao_cancel(struct comedi_device *dev,
 	/* prevent other CPUs from submitting a command just now */
 	down(&this_usbduxsub->sem);
 	/* unlink only if it is really running */
-	res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running);
+	res = usbdux_ao_stop(dev, this_usbduxsub->ao_cmd_running);
 	up(&this_usbduxsub->sem);
 	return res;
 }
@@ -494,7 +489,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 		if (devpriv->ao_cmd_running) {
 			s->async->events |= COMEDI_CB_EOA;
 			comedi_event(dev, s);
-			usbdux_ao_stop(devpriv, 0);
+			usbdux_ao_stop(dev, 0);
 		}
 		return;
 
@@ -508,7 +503,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 			s->async->events |= COMEDI_CB_EOA;
 			comedi_event(dev, s);
 			/* we do an unlink if we are in the high speed mode */
-			usbdux_ao_stop(devpriv, 0);
+			usbdux_ao_stop(dev, 0);
 		}
 		return;
 	}
@@ -529,7 +524,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 			devpriv->ao_sample_count--;
 			if (devpriv->ao_sample_count < 0) {
 				/* all samples transmitted */
-				usbdux_ao_stop(devpriv, 0);
+				usbdux_ao_stop(dev, 0);
 				s->async->events |= COMEDI_CB_EOA;
 				comedi_event(dev, s);
 				/* no resubmit of the urb */
@@ -588,7 +583,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 			s->async->events |= COMEDI_CB_ERROR;
 			comedi_event(dev, s);
 			/* don't do an unlink here */
-			usbdux_ao_stop(devpriv, 0);
+			usbdux_ao_stop(dev, 0);
 		}
 	}
 }
-- 
1.8.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux