staging: comedi: addi_common.h: remove 'ui_AiNbrofScans' from private data
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 29 Apr 2014 19:59:46 +0000 (12:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 May 2014 00:06:33 +0000 (20:06 -0400)
This member of the private data is a copy of the cmd->stop_arg. Use that
instead.

Fix the b_AiContinuous check in apci3120_ai_cmd(). The (*do_cmdtest) validates
that the cmd->stop_arg os >= 1 for TRIG_COUNT and 0 for TRIG_NONE. The correct
test to set this flag is (cmd->stop_src == TRIG_NONE).

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 a2208e7a360564753fb00be0176364f0feb95b6a..7471a0a9e13ef0a338d08d251a0bea39b73cd1ac 100644 (file)
@@ -123,7 +123,6 @@ struct addi_private {
        unsigned int ui_AiNbrofChannels;        /*  how many channels is measured */
        unsigned int ui_AiChannelList[32];      /*  actual chanlist */
        unsigned int ui_AiReadData[32];
-       unsigned int ui_AiNbrofScans;   /*  number of scans to do */
        unsigned short us_UseDma;       /*  To use Dma or not */
        unsigned char b_DmaDoubleBuffer;        /*  we can use double buffering */
        unsigned int ui_DmaActualBuffer;        /*  which buffer is used now */
index cd8e9335aa6e1c1563a98eb1f0f981387848cc5b..e4b92767b8ad7cf9085363e4b3769bcccd0aacd0 100644 (file)
@@ -891,7 +891,7 @@ static int apci3120_cyclic_ai(int mode,
        devpriv->ui_DmaActualBuffer = 0;
 
        /*  value for timer2  minus -2 has to be done .....dunno y?? */
-       ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2;
+       ui_TimerValue2 = cmd->stop_arg - 2;
        ui_ConvertTiming = cmd->convert_arg;
 
        if (mode == 2)
@@ -1130,11 +1130,12 @@ static int apci3120_cyclic_ai(int mode,
                         * Must we fill full first buffer? And must we fill
                         * full second buffer when first is once filled?
                         */
-                       if (dmalen0 > (devpriv->ui_AiNbrofScans * scan_bytes)) {
-                               dmalen0 = devpriv->ui_AiNbrofScans * scan_bytes;
-                       } else if (dmalen1 > (devpriv->ui_AiNbrofScans * scan_bytes - dmalen0))
-                               dmalen1 = devpriv->ui_AiNbrofScans *
-                                         scan_bytes - dmalen0;
+                       if (dmalen0 > (cmd->stop_arg * scan_bytes)) {
+                               dmalen0 = cmd->stop_arg * scan_bytes;
+                       } else if (dmalen1 > (cmd->stop_arg * scan_bytes -
+                                             dmalen0))
+                               dmalen1 = cmd->stop_arg * scan_bytes -
+                                         dmalen0;
                }
 
                if (cmd->flags & TRIG_WAKE_EOS) {
@@ -1339,12 +1340,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
        /* loading private structure with cmd structure inputs */
        devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
 
-       if (cmd->stop_src == TRIG_COUNT)
-               devpriv->ui_AiNbrofScans = cmd->stop_arg;
-       else
-               devpriv->ui_AiNbrofScans = 0;
-
-       if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
+       if (cmd->stop_src == TRIG_NONE)
                devpriv->b_AiContinuous = 1;    /*  user want neverending analog acquisition */
        /*  stopped using cancel */
 
@@ -1486,7 +1482,7 @@ static void apci3120_interrupt_dma(int irq, void *d)
                }
        }
        if (!devpriv->b_AiContinuous)
-               if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
+               if (devpriv->ui_AiActualScan >= cmd->stop_arg) {
                        /*  all data sampled */
                        apci3120_cancel(dev, s);
                        devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;