[PATCH 33/77] staging: comedi: usbduxsigma: tidy up usbdux_ao_inttrig()

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

 



Rename the function so it has namespace associated with the driver.

Rename the local variable used for the private data pointer.

Remove the dev_err() messages, they are just added noise.

Refactor the code to remove the goto.

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 | 47 ++++++++++++----------------
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index e331ef5..5cdba42 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1093,37 +1093,30 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
 	return i;
 }
 
-static int usbdux_ao_inttrig(struct comedi_device *dev,
-			     struct comedi_subdevice *s, unsigned int trignum)
+static int usbduxsigma_ao_inttrig(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  unsigned int trignum)
 {
-	struct usbduxsigma_private *this_usbduxsub = dev->private;
+	struct usbduxsigma_private *devpriv = dev->private;
 	int ret;
 
-	down(&this_usbduxsub->sem);
-	if (trignum != 0) {
-		dev_err(&this_usbduxsub->interface->dev,
-			"comedi%d: usbdux_ao_inttrig: invalid trignum\n",
-			dev->minor);
-		ret = -EINVAL;
-		goto out;
-	}
-	if (!(this_usbduxsub->ao_cmd_running)) {
-		ret = usbduxsigma_submit_urbs(dev, this_usbduxsub->urbOut,
-					      this_usbduxsub->numOfOutBuffers,
-					      0);
-		if (ret < 0)
-			goto out;
-		this_usbduxsub->ao_cmd_running = 1;
+	if (trignum != 0)
+		return -EINVAL;
+
+	down(&devpriv->sem);
+	if (!devpriv->ao_cmd_running) {
+		ret = usbduxsigma_submit_urbs(dev, devpriv->urbOut,
+					      devpriv->numOfOutBuffers, 0);
+		if (ret < 0) {
+			up(&devpriv->sem);
+			return ret;
+		}
+		devpriv->ao_cmd_running = 1;
 		s->async->inttrig = NULL;
-	} else {
-		dev_err(&this_usbduxsub->interface->dev,
-			"comedi%d: ao_inttrig but acqu is already running.\n",
-			dev->minor);
 	}
-	ret = 1;
-out:
-	up(&this_usbduxsub->sem);
-	return ret;
+	up(&devpriv->sem);
+
+	return 1;
 }
 
 static int usbdux_ao_cmdtest(struct comedi_device *dev,
@@ -1287,7 +1280,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		/* TRIG_INT */
 		/* submit the urbs later */
 		/* wait for an internal signal */
-		s->async->inttrig = usbdux_ao_inttrig;
+		s->async->inttrig = usbduxsigma_ao_inttrig;
 	}
 
 	up(&this_usbduxsub->sem);
-- 
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