The validation of the cmd->stop_arg when the cmd->stop_src == TRIG_EXT
is a bit over thought. The comments state that the stop_arg is validated
to force an external trigger of 0 and allow the CR_EDGE flag, which is
ignored. In reality the stop_arg is not even used by the driver when
the stop_src is TRIG_EXT.

Simplify the validation so that the stop_arg must simply be '0' when
the stop_src is TRIG_EXT.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/amplc_pci224.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c 
b/drivers/staging/comedi/drivers/amplc_pci224.c
index 8a55482..3b55e71 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -775,27 +775,10 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct 
comedi_subdevice *s,
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
-       switch (cmd->stop_src) {
-       case TRIG_COUNT:
+       if (cmd->stop_src == TRIG_COUNT)
                err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
-               break;
-       case TRIG_EXT:
-               /* Force to external trigger 0. */
-               if (cmd->stop_arg & ~CR_FLAGS_MASK) {
-                       cmd->stop_arg =
-                           COMBINE(cmd->stop_arg, 0, ~CR_FLAGS_MASK);
-                       err |= -EINVAL;
-               }
-               /* The only flag allowed is CR_EDGE, which is ignored. */
-               if (cmd->stop_arg & CR_FLAGS_MASK & ~CR_EDGE) {
-                       cmd->stop_arg =
-                           COMBINE(cmd->stop_arg, 0, CR_FLAGS_MASK & ~CR_EDGE);
-               }
-               break;
-       case TRIG_NONE:
+       else    /* TRIG_EXT | TRIG_NONE */
                err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
-               break;
-       }
 
        if (err)
                return 3;
-- 
2.0.3

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to