staging: comedi: pcl816: use comedi_timeout()
Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
625791ec76
commit
c0c3531b59
1 changed files with 22 additions and 23 deletions
|
@ -160,16 +160,25 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
|
||||||
struct comedi_cmd *cmd);
|
struct comedi_cmd *cmd);
|
||||||
static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
|
static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
|
||||||
|
|
||||||
/*
|
static int pcl816_ai_eoc(struct comedi_device *dev,
|
||||||
==============================================================================
|
struct comedi_subdevice *s,
|
||||||
ANALOG INPUT MODE0, 816 cards, slow version
|
struct comedi_insn *insn,
|
||||||
*/
|
unsigned long context)
|
||||||
|
{
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
|
status = inb(dev->iobase + PCL816_STATUS);
|
||||||
|
if ((status & PCL816_STATUS_DRDY_MASK) == 0)
|
||||||
|
return 0;
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
static int pcl816_ai_insn_read(struct comedi_device *dev,
|
static int pcl816_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 + PCL816_CONTROL);
|
outb(0, dev->iobase + PCL816_CONTROL);
|
||||||
|
@ -185,30 +194,20 @@ static int pcl816_ai_insn_read(struct comedi_device *dev,
|
||||||
|
|
||||||
outb(0, dev->iobase + PCL816_AD_LO); /* start conversion */
|
outb(0, dev->iobase + PCL816_AD_LO); /* start conversion */
|
||||||
|
|
||||||
timeout = 100;
|
ret = comedi_timeout(dev, s, insn, pcl816_ai_eoc, 0);
|
||||||
while (timeout--) {
|
if (ret) {
|
||||||
if (!(inb(dev->iobase + PCL816_STATUS) &
|
|
||||||
PCL816_STATUS_DRDY_MASK)) {
|
|
||||||
/* return read value */
|
|
||||||
data[n] =
|
|
||||||
((inb(dev->iobase +
|
|
||||||
PCL816_AD_HI) << 8) |
|
|
||||||
(inb(dev->iobase + PCL816_AD_LO)));
|
|
||||||
/* clear INT (conversion end) flag */
|
|
||||||
outb(0, dev->iobase + PCL816_CLRINT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
udelay(1);
|
|
||||||
}
|
|
||||||
/* Return timeout error */
|
|
||||||
if (!timeout) {
|
|
||||||
comedi_error(dev, "A/D insn timeout\n");
|
comedi_error(dev, "A/D insn timeout\n");
|
||||||
data[0] = 0;
|
data[0] = 0;
|
||||||
/* clear INT (conversion end) flag */
|
/* clear INT (conversion end) flag */
|
||||||
outb(0, dev->iobase + PCL816_CLRINT);
|
outb(0, dev->iobase + PCL816_CLRINT);
|
||||||
return -EIO;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return read value */
|
||||||
|
data[n] = ((inb(dev->iobase + PCL816_AD_HI) << 8) |
|
||||||
|
(inb(dev->iobase + PCL816_AD_LO)));
|
||||||
|
/* clear INT (conversion end) flag */
|
||||||
|
outb(0, dev->iobase + PCL816_CLRINT);
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue