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

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: 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 dcdf1d03
...@@ -43,28 +43,26 @@ Configuration options: ...@@ -43,28 +43,26 @@ Configuration options:
static int dt2817_dio_insn_config(struct comedi_device *dev, static int dt2817_dio_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)
{ {
int mask; unsigned int chan = CR_CHAN(insn->chanspec);
int chan; unsigned int oe = 0;
int oe = 0; unsigned int mask;
int ret;
if (insn->n != 1)
return -EINVAL;
chan = CR_CHAN(insn->chanspec);
if (chan < 8) if (chan < 8)
mask = 0xff; mask = 0x000000ff;
else if (chan < 16) else if (chan < 16)
mask = 0xff00; mask = 0x0000ff00;
else if (chan < 24) else if (chan < 24)
mask = 0xff0000; mask = 0x00ff0000;
else else
mask = 0xff000000; mask = 0xff000000;
if (data[0])
s->io_bits |= mask; ret = comedi_dio_insn_config(dev, s, insn, data, mask);
else if (ret)
s->io_bits &= ~mask; return ret;
if (s->io_bits & 0x000000ff) if (s->io_bits & 0x000000ff)
oe |= 0x1; oe |= 0x1;
...@@ -77,7 +75,7 @@ static int dt2817_dio_insn_config(struct comedi_device *dev, ...@@ -77,7 +75,7 @@ static int dt2817_dio_insn_config(struct comedi_device *dev,
outb(oe, dev->iobase + DT2817_CR); outb(oe, dev->iobase + DT2817_CR);
return 1; return insn->n;
} }
static int dt2817_dio_insn_bits(struct comedi_device *dev, static int dt2817_dio_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