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

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

staging: comedi: ni_mio_common: factor out chanlist checking from (*do_cmdtest)



Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible
with the hardware.

Remove the unnecessary step 5 code in the analog output async command support.

For aesthetics, factor out the step 5 code for the "cdio" async command support.
Tidy up the factored out code.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8f61419f
Loading
Loading
Loading
Loading
+19 −12
Original line number Original line Diff line number Diff line
@@ -3304,11 +3304,6 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
	if (err)
	if (err)
		return 4;
		return 4;


	/* step 5: fix up chanlist */

	if (err)
		return 5;

	return 0;
	return 0;
}
}


@@ -3439,12 +3434,27 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
	return insn->n;
	return insn->n;
}
}


static int ni_cdio_check_chanlist(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_cmd *cmd)
{
	int i;

	for (i = 0; i < cmd->chanlist_len; ++i) {
		unsigned int chan = CR_CHAN(cmd->chanlist[i]);

		if (chan != i)
			return -EINVAL;
	}

	return 0;
}

static int ni_cdio_cmdtest(struct comedi_device *dev,
static int ni_cdio_cmdtest(struct comedi_device *dev,
			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
{
	int err = 0;
	int err = 0;
	int tmp;
	int tmp;
	unsigned i;


	/* Step 1 : check if triggers are trivially valid */
	/* Step 1 : check if triggers are trivially valid */


@@ -3484,12 +3494,9 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
	if (err)
	if (err)
		return 4;
		return 4;


	/* step 5: check chanlist */
	/* Step 5: check channel list if it exists */

	if (cmd->chanlist && cmd->chanlist_len > 0)
	for (i = 0; i < cmd->chanlist_len; ++i) {
		err |= ni_cdio_check_chanlist(dev, s, cmd);
		if (cmd->chanlist[i] != i)
			err = 1;
	}


	if (err)
	if (err)
		return 5;
		return 5;