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

staging: comedi: das1800: use comedi_timeout()

Use the helper function to handle the busywaiting for the analog
input conversion to complete.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7b1924b6
...@@ -937,6 +937,19 @@ static int das1800_ai_cmd(struct comedi_device *dev, ...@@ -937,6 +937,19 @@ static int das1800_ai_cmd(struct comedi_device *dev,
return 0; return 0;
} }
static int das1800_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned char status;
status = inb(dev->iobase + DAS1800_STATUS);
if (status & FNE)
return 0;
return -EBUSY;
}
static int das1800_ai_insn_read(struct comedi_device *dev, static int das1800_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
...@@ -944,8 +957,8 @@ static int das1800_ai_insn_read(struct comedi_device *dev, ...@@ -944,8 +957,8 @@ static int das1800_ai_insn_read(struct comedi_device *dev,
{ {
unsigned int range = CR_RANGE(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec);
bool is_unipolar = comedi_range_is_unipolar(s, range); bool is_unipolar = comedi_range_is_unipolar(s, range);
int i, n; int ret = 0;
int timeout = 1000; int n;
unsigned short dpnt; unsigned short dpnt;
unsigned long flags; unsigned long flags;
...@@ -966,24 +979,19 @@ static int das1800_ai_insn_read(struct comedi_device *dev, ...@@ -966,24 +979,19 @@ static int das1800_ai_insn_read(struct comedi_device *dev,
for (n = 0; n < insn->n; n++) { for (n = 0; n < insn->n; n++) {
/* trigger conversion */ /* trigger conversion */
outb(0, dev->iobase + DAS1800_FIFO); outb(0, dev->iobase + DAS1800_FIFO);
for (i = 0; i < timeout; i++) {
if (inb(dev->iobase + DAS1800_STATUS) & FNE) ret = comedi_timeout(dev, s, insn, das1800_ai_eoc, 0);
break; if (ret)
} break;
if (i == timeout) {
dev_err(dev->class_dev, "timeout\n");
n = -ETIME;
goto exit;
}
dpnt = inw(dev->iobase + DAS1800_FIFO); dpnt = inw(dev->iobase + DAS1800_FIFO);
if (!is_unipolar) if (!is_unipolar)
dpnt = comedi_offset_munge(s, dpnt); dpnt = comedi_offset_munge(s, dpnt);
data[n] = dpnt; data[n] = dpnt;
} }
exit:
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
return n; return ret ? ret : insn->n;
} }
static int das1800_ao_insn_write(struct comedi_device *dev, static int das1800_ao_insn_write(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