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

staging: comedi: adl_pci9111: 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 03ff5898
...@@ -84,7 +84,6 @@ a multiple of chanlist_len*convert_arg. ...@@ -84,7 +84,6 @@ a multiple of chanlist_len*convert_arg.
#define PCI9111_RANGE_SETTING_DELAY 10 #define PCI9111_RANGE_SETTING_DELAY 10
#define PCI9111_AI_INSTANT_READ_UDELAY_US 2 #define PCI9111_AI_INSTANT_READ_UDELAY_US 2
#define PCI9111_AI_INSTANT_READ_TIMEOUT 100
/* /*
* IO address map and bit defines * IO address map and bit defines
...@@ -707,6 +706,19 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) ...@@ -707,6 +706,19 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int pci9111_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + PCI9111_AI_RANGE_STAT_REG);
if (status & PCI9111_AI_STAT_FF_EF)
return 0;
return -EBUSY;
}
static int pci9111_ai_insn_read(struct comedi_device *dev, static int pci9111_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)
...@@ -717,7 +729,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, ...@@ -717,7 +729,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
unsigned int invert = (maxdata + 1) >> 1; unsigned int invert = (maxdata + 1) >> 1;
unsigned int shift = (maxdata == 0xffff) ? 0 : 4; unsigned int shift = (maxdata == 0xffff) ? 0 : 4;
unsigned int status; unsigned int status;
int timeout; int ret;
int i; int i;
outb(chan, dev->iobase + PCI9111_AI_CHANNEL_REG); outb(chan, dev->iobase + PCI9111_AI_CHANNEL_REG);
...@@ -734,22 +746,14 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, ...@@ -734,22 +746,14 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
/* Generate a software trigger */ /* Generate a software trigger */
outb(0, dev->iobase + PCI9111_SOFT_TRIG_REG); outb(0, dev->iobase + PCI9111_SOFT_TRIG_REG);
timeout = PCI9111_AI_INSTANT_READ_TIMEOUT; ret = comedi_timeout(dev, s, insn, pci9111_ai_eoc, 0);
if (ret) {
while (timeout--) { comedi_error(dev, "A/D read timeout");
status = inb(dev->iobase + PCI9111_AI_RANGE_STAT_REG); data[i] = 0;
/* '1' means FIFO is not empty */ pci9111_fifo_reset(dev);
if (status & PCI9111_AI_STAT_FF_EF) return ret;
goto conversion_done;
} }
comedi_error(dev, "A/D read timeout");
data[i] = 0;
pci9111_fifo_reset(dev);
return -ETIME;
conversion_done:
data[i] = inw(dev->iobase + PCI9111_AI_FIFO_REG); data[i] = inw(dev->iobase + PCI9111_AI_FIFO_REG);
data[i] = ((data[i] >> shift) & maxdata) ^ invert; data[i] = ((data[i] >> shift) & maxdata) ^ invert;
} }
......
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