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

staging: comedi: s526: 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 3d21960b
...@@ -420,15 +420,28 @@ static int s526_ai_insn_config(struct comedi_device *dev, ...@@ -420,15 +420,28 @@ static int s526_ai_insn_config(struct comedi_device *dev,
return result; return result;
} }
static int s526_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inw(dev->iobase + REG_ISR);
if (status & ISR_ADC_DONE)
return 0;
return -EBUSY;
}
static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
int n, i; int n;
unsigned short value; unsigned short value;
unsigned int d; unsigned int d;
unsigned int status; int ret;
/* Set configured delay, enable channel for this channel only, /* Set configured delay, enable channel for this channel only,
* select "ADC read" channel, set "ADC start" bit. */ * select "ADC read" channel, set "ADC start" bit. */
...@@ -440,17 +453,12 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -440,17 +453,12 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* trigger conversion */ /* trigger conversion */
outw(value, dev->iobase + REG_ADC); outw(value, dev->iobase + REG_ADC);
#define TIMEOUT 100
/* wait for conversion to end */ /* wait for conversion to end */
for (i = 0; i < TIMEOUT; i++) { ret = comedi_timeout(dev, s, insn, s526_ai_eoc, 0);
status = inw(dev->iobase + REG_ISR); if (ret)
if (status & ISR_ADC_DONE) { return ret;
outw(ISR_ADC_DONE, dev->iobase + REG_ISR);
break; outw(ISR_ADC_DONE, dev->iobase + REG_ISR);
}
}
if (i == TIMEOUT)
return -ETIMEDOUT;
/* read data */ /* read data */
d = inw(dev->iobase + REG_ADD); d = inw(dev->iobase + REG_ADD);
......
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