]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Nov 2014 17:54:51 +0000 (10:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Nov 2014 17:34:02 +0000 (09:34 -0800)
This functon is called by apci3120_ai_cmd() with one additional parameter,
'mode', The 'mode' is based on the cmd->scan_begin_src.

For aesthetics, absorb the function into apci3120_ai_cmd() and use the
cmd->scan_begin_src directly to determine the 'mode'.

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 b4d6fb467362c5516db07b9c207e0c7fea26179e..8fc78039bfacd509a6969f273765141dd73ced9c 100644 (file)
@@ -368,15 +368,8 @@ static void apci3120_setup_dma(struct comedi_device *dev,
        /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 }
 
-/*
- * This is used for analog input cyclic acquisition.
- * Performs the command operations.
- * If DMA is configured does DMA initialization otherwise does the
- * acquisition with EOS interrupt.
- */
-static int apci3120_cyclic_ai(int mode,
-                             struct comedi_device *dev,
-                             struct comedi_subdevice *s)
+static int apci3120_ai_cmd(struct comedi_device *dev,
+                          struct comedi_subdevice *s)
 {
        struct apci3120_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
@@ -399,7 +392,7 @@ static int apci3120_cyclic_ai(int mode,
        apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist);
 
        divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags);
-       if (mode == 2) {
+       if (cmd->scan_begin_src == TRIG_TIMER) {
                divisor1 = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg,
                                                cmd->flags);
        }
@@ -411,16 +404,13 @@ static int apci3120_cyclic_ai(int mode,
                devpriv->b_ExttrigEnable = 0;
        }
 
-       switch (mode) {
-       case 1:
+       if (cmd->scan_begin_src == TRIG_FOLLOW) {
                /*  init timer0 in mode 2 */
                apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2);
 
                /* Set the conversion time */
                apci3120_timer_write(dev, 0, divisor0);
-               break;
-
-       case 2:
+       } else {        /* TRIG_TIMER */
                /*  init timer1 in mode 2 */
                apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2);
 
@@ -432,8 +422,6 @@ static int apci3120_cyclic_ai(int mode,
 
                /* Set the conversion time */
                apci3120_timer_write(dev, 0, divisor0);
-               break;
-
        }
 
        outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG);
@@ -471,33 +459,14 @@ static int apci3120_cyclic_ai(int mode,
                }
        }
 
-       switch (mode) {
-       case 1:
+       if (cmd->scan_begin_src == TRIG_FOLLOW) {
                apci3120_timer_enable(dev, 0, true);
-               break;
-       case 2:
+       } else {        /* TRIG_TIMER */
                apci3120_timer_enable(dev, 1, true);
                apci3120_timer_enable(dev, 0, true);
-               break;
        }
 
        return 0;
-
-}
-
-/*
- * Does asynchronous acquisition.
- * Determines the mode 1 or 2.
- */
-static int apci3120_ai_cmd(struct comedi_device *dev,
-                          struct comedi_subdevice *s)
-{
-       struct comedi_cmd *cmd = &s->async->cmd;
-
-       if (cmd->scan_begin_src == TRIG_FOLLOW)
-               return apci3120_cyclic_ai(1, dev, s);
-       /* TRIG_TIMER */
-       return apci3120_cyclic_ai(2, dev, s);
 }
 
 /*