Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b41b267d authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: das800: trigger sources are validated in (*do_cmdtest)



The trigger sources were already validataed in the (*do_cmdtest) before the
(*do_cmd) is called. Refactor the code in das800_ai_do_cmd() to use if/else
instead of the switch since the default cases can never be reached.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f45cc79a
Loading
Loading
Loading
Loading
+3 −14
Original line number Original line Diff line number Diff line
@@ -420,17 +420,12 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
	gain &= 0xf;
	gain &= 0xf;
	outb(gain, dev->iobase + DAS800_GAIN);
	outb(gain, dev->iobase + DAS800_GAIN);


	switch (async->cmd.stop_src) {
	if (async->cmd.stop_src == TRIG_COUNT) {
	case TRIG_COUNT:
		devpriv->count = async->cmd.stop_arg * async->cmd.chanlist_len;
		devpriv->count = async->cmd.stop_arg * async->cmd.chanlist_len;
		devpriv->forever = false;
		devpriv->forever = false;
		break;
	} else {	/* TRIG_NONE */
	case TRIG_NONE:
		devpriv->forever = true;
		devpriv->forever = true;
		devpriv->count = 0;
		devpriv->count = 0;
		break;
	default:
		break;
	}
	}


	/* enable auto channel scan, send interrupts on end of conversion
	/* enable auto channel scan, send interrupts on end of conversion
@@ -440,19 +435,13 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
	conv_bits |= EACS | IEOC;
	conv_bits |= EACS | IEOC;
	if (async->cmd.start_src == TRIG_EXT)
	if (async->cmd.start_src == TRIG_EXT)
		conv_bits |= DTEN;
		conv_bits |= DTEN;
	switch (async->cmd.convert_src) {
	if (async->cmd.convert_src == TRIG_TIMER) {
	case TRIG_TIMER:
		conv_bits |= CASC | ITE;
		conv_bits |= CASC | ITE;
		/* set conversion frequency */
		/* set conversion frequency */
		if (das800_set_frequency(dev) < 0) {
		if (das800_set_frequency(dev) < 0) {
			comedi_error(dev, "Error setting up counters");
			comedi_error(dev, "Error setting up counters");
			return -1;
			return -1;
		}
		}
		break;
	case TRIG_EXT:
		break;
	default:
		break;
	}
	}


	spin_lock_irqsave(&dev->spinlock, irq_flags);
	spin_lock_irqsave(&dev->spinlock, irq_flags);