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

staging: comedi: mf6x4: 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 83b4d991
...@@ -133,21 +133,18 @@ static int mf6x4_do_insn_bits(struct comedi_device *dev, ...@@ -133,21 +133,18 @@ static int mf6x4_do_insn_bits(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int mf6x4_ai_wait_for_eoc(struct comedi_device *dev, static int mf6x4_ai_eoc(struct comedi_device *dev,
unsigned int timeout) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{ {
struct mf6x4_private *devpriv = dev->private; struct mf6x4_private *devpriv = dev->private;
unsigned int eolc; unsigned int status;
while (timeout--) { status = ioread32(devpriv->gpioc_R);
eolc = ioread32(devpriv->gpioc_R) & MF6X4_GPIOC_EOLC; if (status & MF6X4_GPIOC_EOLC)
if (eolc)
return 0; return 0;
return -EBUSY;
udelay(1);
}
return -ETIME;
} }
static int mf6x4_ai_insn_read(struct comedi_device *dev, static int mf6x4_ai_insn_read(struct comedi_device *dev,
...@@ -168,7 +165,7 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev, ...@@ -168,7 +165,7 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev,
/* Trigger ADC conversion by reading ADSTART */ /* Trigger ADC conversion by reading ADSTART */
ioread16(devpriv->bar1_mem + MF6X4_ADSTART_R); ioread16(devpriv->bar1_mem + MF6X4_ADSTART_R);
ret = mf6x4_ai_wait_for_eoc(dev, 100); ret = comedi_timeout(dev, s, insn, mf6x4_ai_eoc, 0);
if (ret) if (ret)
return ret; return ret;
......
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