[PATCH 22/67 v2] staging: comedi: pcl816: reduce indent level in pcl816_ai_cancel()

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

 



If an async command is not running the (*cancel) function doesn't do
anything. Exit the function early if this is the case.

This allows reducing the indent level in the rest of the function.

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

diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 3659986..d6dae54 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -549,37 +549,38 @@ static int pcl816_ai_cancel(struct comedi_device *dev,
 {
 	struct pcl816_private *devpriv = dev->private;
 
-	if (devpriv->ai_cmd_running) {
-		switch (devpriv->int816_mode) {
-		case INT_TYPE_AI1_DMA:
-		case INT_TYPE_AI3_DMA:
-			disable_dma(devpriv->dma);
-			outb(inb(dev->iobase + PCL816_CONTROL) & 0x73,
-			     dev->iobase + PCL816_CONTROL);	/* Stop A/D */
-			udelay(1);
-			outb(0, dev->iobase + PCL816_CONTROL);	/* Stop A/D */
-
-			/* Stop pacer */
-			i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
-				       2, I8254_MODE0 | I8254_BINARY);
-			i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
-				       1, I8254_MODE0 | I8254_BINARY);
-
-			outb(0, dev->iobase + PCL816_AD_LO);
-			pcl816_ai_get_sample(dev, s);
-
-			/* clear INT request */
-			outb(0, dev->iobase + PCL816_CLRINT);
+	if (!devpriv->ai_cmd_running)
+		return 0;
 
-			/* Stop A/D */
-			outb(0, dev->iobase + PCL816_CONTROL);
-			devpriv->ai_cmd_running = 0;
-			devpriv->irq_was_now_closed = 1;
-			devpriv->int816_mode = 0;
-/* s->busy = 0; */
-			break;
-		}
+	switch (devpriv->int816_mode) {
+	case INT_TYPE_AI1_DMA:
+	case INT_TYPE_AI3_DMA:
+		disable_dma(devpriv->dma);
+		outb(inb(dev->iobase + PCL816_CONTROL) & 0x73,
+			dev->iobase + PCL816_CONTROL);	/* Stop A/D */
+		udelay(1);
+		outb(0, dev->iobase + PCL816_CONTROL);	/* Stop A/D */
+
+		/* Stop pacer */
+		i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
+				2, I8254_MODE0 | I8254_BINARY);
+		i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
+				1, I8254_MODE0 | I8254_BINARY);
+
+		outb(0, dev->iobase + PCL816_AD_LO);
+		pcl816_ai_get_sample(dev, s);
+
+		/* clear INT request */
+		outb(0, dev->iobase + PCL816_CLRINT);
+
+		/* Stop A/D */
+		outb(0, dev->iobase + PCL816_CONTROL);
+		devpriv->ai_cmd_running = 0;
+		devpriv->irq_was_now_closed = 1;
+		devpriv->int816_mode = 0;
+		break;
 	}
+
 	return 0;
 }
 
-- 
1.8.5.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