staging: comedi: addi_apci_3120: tidy up apci3120_exttrig_{enable,disable}()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Nov 2014 17:54:01 +0000 (10:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Nov 2014 17:33:58 +0000 (09:33 -0800)
Merge these two functions and use an 'enable' parameter to determine if the
external trigger needs to be enabled or disabled.

This function always succeeds and the callers don't check the return. Change
the return type to void.

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/addi-data/hwdrv_apci3120.c

index 77704685e108df8496e1139b3e88119c590db7fa..30606c947530f1c826c1659f43493926cafcc50b 100644 (file)
@@ -477,22 +477,15 @@ static int apci3120_reset(struct comedi_device *dev)
        return 0;
 }
 
-static int apci3120_exttrig_enable(struct comedi_device *dev)
+static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable)
 {
        struct apci3120_private *devpriv = dev->private;
 
-       devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG;
-       outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
-       return 0;
-}
-
-static int apci3120_exttrig_disable(struct comedi_device *dev)
-{
-       struct apci3120_private *devpriv = dev->private;
-
-       devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG;
+       if (enable)
+               devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG;
+       else
+               devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG;
        outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
-       return 0;
 }
 
 static int apci3120_cancel(struct comedi_device *dev,
@@ -649,7 +642,8 @@ static int apci3120_cyclic_ai(int mode,
        }
 
        if (devpriv->b_ExttrigEnable == APCI3120_ENABLE)
-               apci3120_exttrig_enable(dev);   /*  activate EXT trigger */
+               apci3120_exttrig_enable(dev, true);
+
        switch (mode) {
        case 1:
                /*  init timer0 in mode 2 */
@@ -1114,8 +1108,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
        int_daq = (int_daq >> 12) & 0xF;
 
        if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
-               /* Disable ext trigger */
-               apci3120_exttrig_disable(dev);
+               apci3120_exttrig_enable(dev, false);
                devpriv->b_ExttrigEnable = APCI3120_DISABLE;
        }
        /* clear the timer 2 interrupt */