staging: comedi: pcl816: reduce indent level in pcl816_ai_cancel()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Mar 2014 18:29:42 +0000 (11:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2014 01:06:12 +0000 (17:06 -0800)
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@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcl816.c

index 36599861c78bbe6ef609af096facb39a37094c4e..d6dae54660236f79c03018e73dbdecc8290cfac6 100644 (file)
@@ -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;
 }