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

staging: comedi: dt2814: use comedi_timeout()

Use comedi_timeout() to wait for the analog input end-of-conversion.
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 1d6f4af9
...@@ -66,26 +66,35 @@ struct dt2814_private { ...@@ -66,26 +66,35 @@ struct dt2814_private {
#define DT2814_TIMEOUT 10 #define DT2814_TIMEOUT 10
#define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */ #define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */
static int dt2814_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + DT2814_CSR);
if (status & DT2814_FINISH)
return 0;
return -EBUSY;
}
static int dt2814_ai_insn_read(struct comedi_device *dev, static int dt2814_ai_insn_read(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 n, i, hi, lo; int n, hi, lo;
int chan; int chan;
int status = 0; int ret;
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
outb(chan, dev->iobase + DT2814_CSR); outb(chan, dev->iobase + DT2814_CSR);
for (i = 0; i < DT2814_TIMEOUT; i++) {
status = inb(dev->iobase + DT2814_CSR); ret = comedi_timeout(dev, s, insn, dt2814_ai_eoc, 0);
udelay(10); if (ret)
if (status & DT2814_FINISH) return ret;
break;
}
if (i >= DT2814_TIMEOUT)
return -ETIMEDOUT;
hi = inb(dev->iobase + DT2814_DATA); hi = inb(dev->iobase + DT2814_DATA);
lo = inb(dev->iobase + DT2814_DATA); lo = inb(dev->iobase + DT2814_DATA);
......
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