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

staging: comedi: ke_counter: fix ke_counter_insn_read()

The comedi core expects the (*insn_read) functions to read insn->n
values. Fix this function to work like the core expects.

The counters are actually 25-bit (24-bits + 1 sign bit). Instead of munging
the data when the sign bit is set just return the full 25-bit value.
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 99a1b98b
...@@ -76,24 +76,23 @@ static int ke_counter_insn_read(struct comedi_device *dev, ...@@ -76,24 +76,23 @@ static int ke_counter_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
unsigned char a0, a1, a2, a3, a4; unsigned int chan = CR_CHAN(insn->chanspec);
int chan = CR_CHAN(insn->chanspec); unsigned int val;
int result; int i;
a0 = inb(dev->iobase + KE_LATCH_REG(chan)); for (i = 0; i < insn->n; i++) {
a1 = inb(dev->iobase + KE_LSB_REG(chan)); /* Order matters */
a2 = inb(dev->iobase + KE_MID_REG(chan)); inb(dev->iobase + KE_LATCH_REG(chan));
a3 = inb(dev->iobase + KE_MSB_REG(chan));
a4 = inb(dev->iobase + KE_SIGN_REG(chan));
result = (a1 + (a2 * 256) + (a3 * 65536)); val = inb(dev->iobase + KE_LSB_REG(chan));
if (a4 > 0) val |= (inb(dev->iobase + KE_MID_REG(chan)) << 8);
result = result - s->maxdata; val |= (inb(dev->iobase + KE_MSB_REG(chan)) << 16);
val |= (inb(dev->iobase + KE_SIGN_REG(chan)) << 24);
*data = (unsigned int)result; data[i] = val;
}
/* return the number of samples read */ return insn->n;
return 1;
} }
static int cnt_auto_attach(struct comedi_device *dev, static int cnt_auto_attach(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