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

staging: comedi: das16m1: 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 c3ce086e
...@@ -331,14 +331,27 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -331,14 +331,27 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
return 0; return 0;
} }
static int das16m1_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + DAS16M1_CS);
if (status & IRQDATA)
return 0;
return -EBUSY;
}
static int das16m1_ai_rinsn(struct comedi_device *dev, static int das16m1_ai_rinsn(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)
{ {
struct das16m1_private_struct *devpriv = dev->private; struct das16m1_private_struct *devpriv = dev->private;
int i, n; int ret;
int n;
int byte; int byte;
const int timeout = 1000;
/* disable interrupts and internal pacer */ /* disable interrupts and internal pacer */
devpriv->control_state &= ~INTE & ~PACER_MASK; devpriv->control_state &= ~INTE & ~PACER_MASK;
...@@ -356,14 +369,12 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, ...@@ -356,14 +369,12 @@ static int das16m1_ai_rinsn(struct comedi_device *dev,
/* trigger conversion */ /* trigger conversion */
outb(0, dev->iobase); outb(0, dev->iobase);
for (i = 0; i < timeout; i++) { ret = comedi_timeout(dev, s, insn, das16m1_ai_eoc, 0);
if (inb(dev->iobase + DAS16M1_CS) & IRQDATA) if (ret) {
break;
}
if (i == timeout) {
comedi_error(dev, "timeout"); comedi_error(dev, "timeout");
return -ETIME; return ret;
} }
data[n] = munge_sample(inw(dev->iobase)); data[n] = munge_sample(inw(dev->iobase));
} }
......
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