From fe0d96bf5198a06d4620a10f7faba0e596902e72 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Aug 2015 10:14:00 -0700 Subject: [PATCH] staging: comedi: usbduxfast: TRIG_EXT is only valid for cmd->start_src 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 49 ++++++++--------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 1183476..e18b14e 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -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, -- 2.7.4