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

staging: comedi: me4000: use comedi_timeout() to wait for ai (*insn_read)

Use the comedi_timeout() helper to busy-wait for the analog input end-of-
conversion instead of the udelay().
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 a0861f87
...@@ -433,9 +433,18 @@ static void me4000_reset(struct comedi_device *dev) ...@@ -433,9 +433,18 @@ static void me4000_reset(struct comedi_device *dev)
outl(0x1, dev->iobase + ME4000_DIO_CTRL_REG); outl(0x1, dev->iobase + ME4000_DIO_CTRL_REG);
} }
/*============================================================================= static int me4000_ai_eoc(struct comedi_device *dev,
Analog input section struct comedi_subdevice *s,
===========================================================================*/ struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inl(dev->iobase + ME4000_AI_STATUS_REG);
if (status & ME4000_AI_STATUS_BIT_EF_DATA)
return 0;
return -EBUSY;
}
static int me4000_ai_insn_read(struct comedi_device *dev, static int me4000_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
...@@ -445,10 +454,10 @@ static int me4000_ai_insn_read(struct comedi_device *dev, ...@@ -445,10 +454,10 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
int chan = CR_CHAN(insn->chanspec); int chan = CR_CHAN(insn->chanspec);
int rang = CR_RANGE(insn->chanspec); int rang = CR_RANGE(insn->chanspec);
int aref = CR_AREF(insn->chanspec); int aref = CR_AREF(insn->chanspec);
unsigned int entry = 0; unsigned int entry = 0;
unsigned int tmp; unsigned int tmp;
unsigned int lval; unsigned int lval;
int ret;
if (insn->n == 0) { if (insn->n == 0) {
return 0; return 0;
...@@ -509,13 +518,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev, ...@@ -509,13 +518,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
/* Start conversion by dummy read */ /* Start conversion by dummy read */
inl(dev->iobase + ME4000_AI_START_REG); inl(dev->iobase + ME4000_AI_START_REG);
/* Wait until ready */ ret = comedi_timeout(dev, s, insn, me4000_ai_eoc, 0);
udelay(10); if (ret)
if (!(inl(dev->iobase + ME4000_AI_STATUS_REG) & return ret;
ME4000_AI_STATUS_BIT_EF_DATA)) {
dev_err(dev->class_dev, "Value not available after wait\n");
return -EIO;
}
/* Read value from data fifo */ /* Read value from data fifo */
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF; lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
......
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