]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: usbduxfast: TRIG_EXT is only valid for cmd->start_src
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 24 Aug 2015 17:14:00 +0000 (10:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:24 +0000 (18:24 -0700)
According to the code, and verified with the author Bernd Porr, the
TRIG_EXT trigger is only valid for the cmd->start_src. Remove this
trigger from the cmd->scan_begin_src and cmd->convert_src.

The only valid scan_begin_src is then TRIG_FOLLOW  and the convert_src
is only TRIG_TIMER. Remove the redundant unique trigger checks in Step
2b of the (*do_cmdtest) as well as any other unnecessary checks of
those trigger sources.

Also remove the incorrect comment for a cmd->stop_src of TRIG_EXT.

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/usbduxfast.c

index 118347671107382dcfbb50a1646134024c13874f..e18b14e9abbff6556dec7acda87551b6ab309cf9 100644 (file)
@@ -366,10 +366,8 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
        err |= comedi_check_trigger_src(&cmd->start_src,
                                        TRIG_NOW | TRIG_EXT | TRIG_INT);
-       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
-                                       TRIG_FOLLOW | TRIG_EXT);
-       err |= comedi_check_trigger_src(&cmd->convert_src,
-                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
        err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
        err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
@@ -379,16 +377,10 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
        /* Step 2a : make sure trigger sources are unique */
 
        err |= comedi_check_trigger_is_unique(cmd->start_src);
-       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= comedi_check_trigger_is_unique(cmd->convert_src);
        err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
-       /* can't have external stop and start triggers at once */
-       if (cmd->start_src == TRIG_EXT && cmd->stop_src == TRIG_EXT)
-               err |= -EINVAL;
-
        if (err)
                return 2;
 
@@ -412,34 +404,21 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
        else
                min_sample_period = MIN_SAMPLING_PERIOD;
 
-       if (cmd->convert_src == TRIG_TIMER) {
-               steps = cmd->convert_arg * 30;
-               if (steps < (min_sample_period * 1000))
-                       steps = min_sample_period * 1000;
+       steps = cmd->convert_arg * 30;
+       if (steps < (min_sample_period * 1000))
+               steps = min_sample_period * 1000;
 
-               if (steps > (MAX_SAMPLING_PERIOD * 1000))
-                       steps = MAX_SAMPLING_PERIOD * 1000;
+       if (steps > (MAX_SAMPLING_PERIOD * 1000))
+               steps = MAX_SAMPLING_PERIOD * 1000;
 
-               /* calc arg again */
-               tmp = steps / 30;
-               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, tmp);
-       }
+       /* calc arg again */
+       tmp = steps / 30;
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, tmp);
 
-       /* stop source */
-       switch (cmd->stop_src) {
-       case TRIG_COUNT:
+       if (cmd->stop_src == TRIG_COUNT)
                err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
-               break;
-       case TRIG_NONE:
+       else    /* TRIG_NONE */
                err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
-               break;
-               /*
-                * TRIG_EXT doesn't care since it doesn't trigger
-                * off a numbered channel
-                */
-       default:
-               break;
-       }
 
        if (err)
                return 3;
@@ -508,9 +487,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev,
         */
        devpriv->ignore = PACKETS_TO_IGNORE;
 
-       steps = 0;
-       if (cmd->convert_src == TRIG_TIMER)
-               steps = (cmd->convert_arg * 30) / 1000;
+       steps = (cmd->convert_arg * 30) / 1000;
 
        if ((steps < MIN_SAMPLING_PERIOD) && (cmd->chanlist_len != 1)) {
                dev_err(dev->class_dev,