diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-08-26 15:28:32 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-27 16:59:07 -0700 |
commit | c7fe22f6f6e5715d29bdfca99358001c0dfbdae6 (patch) | |
tree | 9108a9571e364963d659a0fbc42a62a55ae96f2d | |
parent | dcdf1d0323a4eea3bc0a1131057f78234d082079 (diff) |
staging: comedi: dt2817: fix dt2817_dio_insn_config()
This is the (*insn_config) function for a DIO subdevice. It should be
using the data[0] value as the "instruction" to perform on the subdevice.
Use the comedi_dio_insn_config() helper to properly handle instructions.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/dt2817.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 51cf1211f1b..f4a8529239b 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -43,28 +43,26 @@ Configuration options: static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int mask; - int chan; - int oe = 0; - - if (insn->n != 1) - return -EINVAL; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int oe = 0; + unsigned int mask; + int ret; - chan = CR_CHAN(insn->chanspec); if (chan < 8) - mask = 0xff; + mask = 0x000000ff; else if (chan < 16) - mask = 0xff00; + mask = 0x0000ff00; else if (chan < 24) - mask = 0xff0000; + mask = 0x00ff0000; else mask = 0xff000000; - if (data[0]) - s->io_bits |= mask; - else - s->io_bits &= ~mask; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; if (s->io_bits & 0x000000ff) oe |= 0x1; @@ -77,7 +75,7 @@ static int dt2817_dio_insn_config(struct comedi_device *dev, outb(oe, dev->iobase + DT2817_CR); - return 1; + return insn->n; } static int dt2817_dio_insn_bits(struct comedi_device *dev, |