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

staging: comedi: pcl818: 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 c0c3531b
...@@ -336,16 +336,25 @@ static int pcl818_ai_cancel(struct comedi_device *dev, ...@@ -336,16 +336,25 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
static void start_pacer(struct comedi_device *dev, int mode, static void start_pacer(struct comedi_device *dev, int mode,
unsigned int divisor1, unsigned int divisor2); unsigned int divisor1, unsigned int divisor2);
/* static int pcl818_ai_eoc(struct comedi_device *dev,
============================================================================== struct comedi_subdevice *s,
ANALOG INPUT MODE0, 818 cards, slow version struct comedi_insn *insn,
*/ unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + PCL818_STATUS);
if (status & 0x10)
return 0;
return -EBUSY;
}
static int pcl818_ai_insn_read(struct comedi_device *dev, static int pcl818_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 ret;
int n; int n;
int timeout;
/* software trigger, DMA and INT off */ /* software trigger, DMA and INT off */
outb(0, dev->iobase + PCL818_CONTROL); outb(0, dev->iobase + PCL818_CONTROL);
...@@ -364,18 +373,14 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, ...@@ -364,18 +373,14 @@ static int pcl818_ai_insn_read(struct comedi_device *dev,
/* start conversion */ /* start conversion */
outb(0, dev->iobase + PCL818_AD_LO); outb(0, dev->iobase + PCL818_AD_LO);
timeout = 100; ret = comedi_timeout(dev, s, insn, pcl818_ai_eoc, 0);
while (timeout--) { if (ret) {
if (inb(dev->iobase + PCL818_STATUS) & 0x10) comedi_error(dev, "A/D insn timeout");
goto conv_finish; /* clear INT (conversion end) flag */
udelay(1); outb(0, dev->iobase + PCL818_CLRINT);
return ret;
} }
comedi_error(dev, "A/D insn timeout");
/* clear INT (conversion end) flag */
outb(0, dev->iobase + PCL818_CLRINT);
return -EIO;
conv_finish:
data[n] = ((inb(dev->iobase + PCL818_AD_HI) << 4) | data[n] = ((inb(dev->iobase + PCL818_AD_HI) << 4) |
(inb(dev->iobase + PCL818_AD_LO) >> 4)); (inb(dev->iobase + PCL818_AD_LO) >> 4));
} }
......
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