staging: comedi: ni_at_a2150: use comedi_timeout()
Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
67562be505
commit
33a6d44bbd
1 changed files with 24 additions and 18 deletions
|
@ -488,13 +488,25 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int a2150_ai_eoc(struct comedi_device *dev,
|
||||||
|
struct comedi_subdevice *s,
|
||||||
|
struct comedi_insn *insn,
|
||||||
|
unsigned long context)
|
||||||
|
{
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
|
status = inw(dev->iobase + STATUS_REG);
|
||||||
|
if (status & FNE_BIT)
|
||||||
|
return 0;
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
static int a2150_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 a2150_private *devpriv = dev->private;
|
struct a2150_private *devpriv = dev->private;
|
||||||
unsigned int i, n;
|
unsigned int n;
|
||||||
static const int timeout = 100000;
|
int ret;
|
||||||
static const int filter_delay = 36;
|
|
||||||
|
|
||||||
/* clear fifo and reset triggering circuitry */
|
/* clear fifo and reset triggering circuitry */
|
||||||
outw(0, dev->iobase + FIFO_RESET_REG);
|
outw(0, dev->iobase + FIFO_RESET_REG);
|
||||||
|
@ -524,30 +536,24 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||||
* there is a 35.6 sample delay for data to get through the
|
* there is a 35.6 sample delay for data to get through the
|
||||||
* antialias filter
|
* antialias filter
|
||||||
*/
|
*/
|
||||||
for (n = 0; n < filter_delay; n++) {
|
for (n = 0; n < 36; n++) {
|
||||||
for (i = 0; i < timeout; i++) {
|
ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0);
|
||||||
if (inw(dev->iobase + STATUS_REG) & FNE_BIT)
|
if (ret) {
|
||||||
break;
|
|
||||||
udelay(1);
|
|
||||||
}
|
|
||||||
if (i == timeout) {
|
|
||||||
comedi_error(dev, "timeout");
|
comedi_error(dev, "timeout");
|
||||||
return -ETIME;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
inw(dev->iobase + FIFO_DATA_REG);
|
inw(dev->iobase + FIFO_DATA_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read data */
|
/* read data */
|
||||||
for (n = 0; n < insn->n; n++) {
|
for (n = 0; n < insn->n; n++) {
|
||||||
for (i = 0; i < timeout; i++) {
|
ret = comedi_timeout(dev, s, insn, a2150_ai_eoc, 0);
|
||||||
if (inw(dev->iobase + STATUS_REG) & FNE_BIT)
|
if (ret) {
|
||||||
break;
|
|
||||||
udelay(1);
|
|
||||||
}
|
|
||||||
if (i == timeout) {
|
|
||||||
comedi_error(dev, "timeout");
|
comedi_error(dev, "timeout");
|
||||||
return -ETIME;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
data[n] = inw(dev->iobase + FIFO_DATA_REG);
|
data[n] = inw(dev->iobase + FIFO_DATA_REG);
|
||||||
data[n] ^= 0x8000;
|
data[n] ^= 0x8000;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue