Commit c6d9681b authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_6527: tidy up ni6527_di_insn_config()

The core will validate the insn->n value based on the actual instruction
(data[0]) that is being handled. Remove the sanity check and change the
instruction handling into a switch. This follows the normal format for
(*insn_config) functions and make adding additional instructions easier.
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 e3f6ce20
...@@ -123,32 +123,36 @@ static void ni6527_set_filter_enable(struct comedi_device *dev, ...@@ -123,32 +123,36 @@ static void ni6527_set_filter_enable(struct comedi_device *dev,
static int ni6527_di_insn_config(struct comedi_device *dev, static int ni6527_di_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct ni6527_private *devpriv = dev->private; struct ni6527_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int interval; unsigned int interval;
if (insn->n != 2) switch (data[0]) {
return -EINVAL; case INSN_CONFIG_FILTER:
/*
if (data[0] != INSN_CONFIG_FILTER) * The deglitch filter interval is specified in nanoseconds.
return -EINVAL; * The hardware supports intervals in 200ns increments. Round
* the user values up and return the actual interval.
if (data[1]) { */
interval = (data[1] + 100) / 200; interval = (data[1] + 100) / 200;
data[1] = interval * 200; data[1] = interval * 200;
if (interval) {
ni6527_set_filter_interval(dev, interval); ni6527_set_filter_interval(dev, interval);
devpriv->filter_enable |= 1 << chan; devpriv->filter_enable |= 1 << chan;
} else { } else {
devpriv->filter_enable &= ~(1 << chan); devpriv->filter_enable &= ~(1 << chan);
} }
ni6527_set_filter_enable(dev, devpriv->filter_enable); ni6527_set_filter_enable(dev, devpriv->filter_enable);
break;
default:
return -EINVAL;
}
return 2; return insn->n;
} }
static int ni6527_di_insn_bits(struct comedi_device *dev, static int ni6527_di_insn_bits(struct comedi_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment