[PATCH 03/77] staging: comedi: usbduxsigma: cleanup the unlink urb functions

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

 



These functions always return success. Change them to just return void.

The 'usbduxsub_tmp', which is actually the comedi_device private data, is
already validated by the callers. Remove the unnecessary validation and
rename the 'usbduxsub_tmp' parameter to 'devpriv' which is more common in
comedi drivers.

Remove the unnecessary comments.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 82 +++++++---------------------
 1 file changed, 20 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index 049a3e2..e284572 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -252,49 +252,29 @@ static struct usbduxsub usbduxsub[NUMUSBDUX];
 
 static DEFINE_SEMAPHORE(start_stop_sem);
 
-/*
- * Stops the data acquision
- * It should be safe to call this function from any context
- */
-static int usbduxsub_unlink_InURBs(struct usbduxsub *usbduxsub_tmp)
+static void usbduxsub_unlink_InURBs(struct usbduxsub *devpriv)
 {
-	int i = 0;
-	int err = 0;
+	int i;
 
-	if (usbduxsub_tmp && usbduxsub_tmp->urbIn) {
-		for (i = 0; i < usbduxsub_tmp->numOfInBuffers; i++) {
-			if (usbduxsub_tmp->urbIn[i]) {
-				/* We wait here until all transfers have been
-				 * cancelled. */
-				usb_kill_urb(usbduxsub_tmp->urbIn[i]);
-			}
-		}
+	for (i = 0; i < devpriv->numOfInBuffers; i++) {
+		if (devpriv->urbIn[i])
+			usb_kill_urb(devpriv->urbIn[i]);
 	}
-	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 usbduxsub *this_usbduxsub, int do_unlink)
 {
-	int ret = 0;
-
 	if (!this_usbduxsub) {
 		pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n");
 		return -EFAULT;
 	}
 
-	if (do_unlink) {
-		/* stop aquistion */
-		ret = usbduxsub_unlink_InURBs(this_usbduxsub);
-	}
+	if (do_unlink)
+		usbduxsub_unlink_InURBs(this_usbduxsub);
 
 	this_usbduxsub->ai_cmd_running = 0;
 
-	return ret;
+	return 0;
 }
 
 /*
@@ -469,36 +449,27 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
 	comedi_event(this_usbduxsub->comedidev, s);
 }
 
-static int usbduxsub_unlink_OutURBs(struct usbduxsub *usbduxsub_tmp)
+static void usbduxsub_unlink_OutURBs(struct usbduxsub *devpriv)
 {
-	int i = 0;
-	int err = 0;
+	int i;
 
-	if (usbduxsub_tmp && usbduxsub_tmp->urbOut) {
-		for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
-			if (usbduxsub_tmp->urbOut[i])
-				usb_kill_urb(usbduxsub_tmp->urbOut[i]);
-		}
+	for (i = 0; i < devpriv->numOfOutBuffers; i++) {
+		if (devpriv->urbOut[i])
+			usb_kill_urb(devpriv->urbOut[i]);
 	}
-	return err;
 }
 
-/* This will cancel a running acquisition operation
- * in any context.
- */
 static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
 {
-	int ret = 0;
-
 	if (!this_usbduxsub)
 		return -EFAULT;
 
 	if (do_unlink)
-		ret = usbduxsub_unlink_OutURBs(this_usbduxsub);
+		usbduxsub_unlink_OutURBs(this_usbduxsub);
 
 	this_usbduxsub->ao_cmd_running = 0;
 
-	return ret;
+	return 0;
 }
 
 /* force unlink, is called by comedi */
@@ -1662,36 +1633,23 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
 	return insn->n;
 }
 
-/***********************************/
-/* PWM */
-
-static int usbduxsub_unlink_PwmURBs(struct usbduxsub *usbduxsub_tmp)
+static void usbduxsub_unlink_PwmURBs(struct usbduxsub *devpriv)
 {
-	int err = 0;
-
-	if (usbduxsub_tmp && usbduxsub_tmp->urbPwm) {
-		if (usbduxsub_tmp->urbPwm)
-			usb_kill_urb(usbduxsub_tmp->urbPwm);
-	}
-	return err;
+	if (devpriv->urbPwm)
+		usb_kill_urb(devpriv->urbPwm);
 }
 
-/* This cancels a running acquisition operation
- * in any context.
- */
 static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
 {
-	int ret = 0;
-
 	if (!this_usbduxsub)
 		return -EFAULT;
 
 	if (do_unlink)
-		ret = usbduxsub_unlink_PwmURBs(this_usbduxsub);
+		usbduxsub_unlink_PwmURBs(this_usbduxsub);
 
 	this_usbduxsub->pwm_cmd_running = 0;
 
-	return ret;
+	return 0;
 }
 
 /* force unlink - is called by comedi */
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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