staging: comedi: hwdrv_apci3120: fix 'b_AiCyclicAcquisition' usage
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 29 Apr 2014 19:59:49 +0000 (12:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 May 2014 00:06:34 +0000 (20:06 -0400)
This private data member is set when an analog input async command is
started by apci3120_cyclic_ai() and cleared when the command finishes
or is canceled.

Rename the CamelCase member to 'ai_running' and convert it to a
bit-field flag.

Remove the unnecessary clearing of the flag before or after calling
apci3120_cancel().

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/addi_common.h
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c

index c55c5dae688ed87ddfb6069733a1f8dd91ed6298..5c6a11c35dede4db2cfcd18a32dccd8d70efee33 100644 (file)
@@ -137,7 +137,7 @@ struct addi_private {
        unsigned short us_OutputRegister;       /*  Contain data written at iobase + 0 */
        unsigned char b_Timer2Mode;     /*  Specify the timer 2 mode */
        unsigned char b_Timer2Interrupt;        /* Timer2  interrupt enable or disable */
-       unsigned char b_AiCyclicAcquisition;    /*  indicate cyclic acquisition */
+       unsigned int ai_running:1;
        unsigned char b_InterruptMode;  /*  eoc eos or dma */
        unsigned char b_EocEosInterrupt;        /*  Enable disable eoc eos interrupt */
        unsigned int ui_EocEosConversionTime;
index 7bc6b8ff8157f9e6366a53293fb2c6c7da1db5eb..8874b2ca4cd956acba306ba38c7b78a698c46d88 100644 (file)
@@ -609,7 +609,7 @@ static int apci3120_reset(struct comedi_device *dev)
        unsigned int i;
        unsigned short us_TmpValue;
 
-       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+       devpriv->ai_running = 0;
        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
        devpriv->b_InterruptMode = APCI3120_EOC_MODE;
        devpriv->ui_EocEosConversionTime = 0;   /*  set eoc eos conv time to 0 */
@@ -722,7 +722,7 @@ static int apci3120_cancel(struct comedi_device *dev,
        s->async->cur_chan = 0;
        devpriv->ui_DmaActualBuffer = 0;
 
-       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+       devpriv->ai_running = 0;
        devpriv->b_InterruptMode = APCI3120_EOC_MODE;
        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
        apci3120_reset(dev);
@@ -817,10 +817,6 @@ static int apci3120_cyclic_ai(int mode,
                0, ui_TimerValue0, ui_ConvertTiming;
        unsigned short us_TmpValue;
 
-       /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
-       /* devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE; */
-       /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
-
        /*******************/
        /* Resets the FIFO */
        /*******************/
@@ -830,12 +826,7 @@ static int apci3120_cyclic_ai(int mode,
        /* inw(dev->iobase+APCI3120_RD_STATUS); */
        /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
-       /***************************/
-       /* Acquisition initialized */
-       /***************************/
-       /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
-       devpriv->b_AiCyclicAcquisition = APCI3120_ENABLE;
-       /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+       devpriv->ai_running = 1;
 
        /*  clear software  registers */
        devpriv->b_TimerSelectMode = 0;
@@ -1388,8 +1379,6 @@ static void apci3120_interrupt_dma(int irq, void *d)
        if (samplesinbuf & 1) {
                comedi_error(dev, "Odd count of bytes in DMA ring!");
                apci3120_cancel(dev, s);
-               devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
-
                return;
        }
        samplesinbuf = samplesinbuf >> 1;       /*  number of received samples */
@@ -1459,7 +1448,6 @@ static void apci3120_interrupt_dma(int irq, void *d)
                if (devpriv->ui_AiActualScan >= cmd->stop_arg) {
                        /*  all data sampled */
                        apci3120_cancel(dev, s);
-                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
                        s->async->events |= COMEDI_CB_EOA;
                        comedi_event(dev, s);
                        return;
@@ -1609,7 +1597,7 @@ static void apci3120_interrupt(int irq, void *d)
 
                if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {    /*  enable this in without DMA ??? */
 
-                       if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
+                       if (devpriv->ai_running) {
                                ui_Check = 0;
                                apci3120_interrupt_handle_eos(dev);
                                devpriv->ui_AiActualScan++;
@@ -1651,8 +1639,6 @@ static void apci3120_interrupt(int irq, void *d)
 
                switch (devpriv->b_Timer2Mode) {
                case APCI3120_COUNTER:
-
-                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
                        devpriv->b_ModeSelectRegister =
                                devpriv->
                                b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
@@ -1668,7 +1654,6 @@ static void apci3120_interrupt(int irq, void *d)
 
                        /* stop timer 0 and timer 1 */
                        apci3120_cancel(dev, s);
-                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
 
                        /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */
                        s->async->events |= COMEDI_CB_EOA;
@@ -1707,7 +1692,7 @@ static void apci3120_interrupt(int irq, void *d)
        }
 
        if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) {
-               if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
+               if (devpriv->ai_running) {
 
                        /****************************/
                        /* Clear Timer Write TC int */