staging: comedi: addi_apci_3120: fix counter and external interrupt disable
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Nov 2014 17:53:50 +0000 (10:53 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Nov 2014 17:33:57 +0000 (09:33 -0800)
The APCI3120_DISABLE_ALL_TIMER define define is not needed, and it's used
incorrectly in apci3120_cancel(). The define is a mask of the bits needed
to disable the counters. Writing the value directly sets unintended bits.

Prior to writing the value, the 'devpriv->us_OutputRegister' is set to 0
and written to the register. This disables all the timers and the external
trigger.

Remove the unnecessary apci3120_exttrig_disable() call as well as the write
of APCI3120_DISABLE_ALL_TIMER.

In apci3120_interrupt(), remove the unnecessary mask and write to disable
all the timers. The COMEDI_CB_EOA event will cause the core to call the
(*cancel) operation which will disable the timers.

Remove the unused define.

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 93b1725..6eaf62a 100644 (file)
@@ -167,9 +167,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 
 #define APCI3120_TIMER2_SELECT_EOS     0xc0
 #define APCI3120_COUNTER               3
-#define APCI3120_DISABLE_ALL_TIMER     (APCI3120_DISABLE_TIMER0 &      \
-                                        APCI3120_DISABLE_TIMER1 &      \
-                                        APCI3120_DISABLE_TIMER2)
 
 /* ANALOG INPUT RANGE */
 static const struct comedi_lrange range_apci3120_ai = {
@@ -613,16 +610,9 @@ static int apci3120_cancel(struct comedi_device *dev,
        /* Disable BUS Master PCI */
        outl(0, devpriv->amcc + AMCC_OP_REG_MCSR);
 
-       /* Disable ext trigger */
-       apci3120_exttrig_disable(dev);
-
+       /* stop all counters and disable external trigger */
        devpriv->us_OutputRegister = 0;
-       /* stop  counters */
-       outw(devpriv->
-               us_OutputRegister & APCI3120_DISABLE_TIMER0 &
-               APCI3120_DISABLE_TIMER1, dev->iobase + APCI3120_WR_ADDRESS);
-
-       outw(APCI3120_DISABLE_ALL_TIMER, dev->iobase + APCI3120_WR_ADDRESS);
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
 
        /* DISABLE_ALL_INTERRUPT */
        outb(APCI3120_DISABLE_ALL_INTERRUPT,
@@ -1346,13 +1336,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
                        outb(devpriv->b_ModeSelectRegister,
                                dev->iobase + APCI3120_WRITE_MODE_SELECT);
 
-                       /*  stop timer 2 */
-                       devpriv->us_OutputRegister =
-                               devpriv->
-                               us_OutputRegister & APCI3120_DISABLE_ALL_TIMER;
-                       outw(devpriv->us_OutputRegister,
-                               dev->iobase + APCI3120_WR_ADDRESS);
-
                        s->async->events |= COMEDI_CB_EOA;
                        break;