staging: comedi: aio_aio12_8: 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:
committed by
Greg Kroah-Hartman
parent
8c5bd90e9f
commit
0862a46f17
@@ -101,14 +101,27 @@ struct aio12_8_private {
|
|||||||
unsigned int ao_readback[4];
|
unsigned int ao_readback[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int aio_aio12_8_ai_eoc(struct comedi_device *dev,
|
||||||
|
struct comedi_subdevice *s,
|
||||||
|
struct comedi_insn *insn,
|
||||||
|
unsigned long context)
|
||||||
|
{
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
|
status = inb(dev->iobase + AIO12_8_STATUS_REG);
|
||||||
|
if (status & AIO12_8_STATUS_ADC_EOC)
|
||||||
|
return 0;
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
static int aio_aio12_8_ai_read(struct comedi_device *dev,
|
static int aio_aio12_8_ai_read(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)
|
||||||
{
|
{
|
||||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||||
unsigned int range = CR_RANGE(insn->chanspec);
|
unsigned int range = CR_RANGE(insn->chanspec);
|
||||||
unsigned int val;
|
|
||||||
unsigned char control;
|
unsigned char control;
|
||||||
|
int ret;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -122,20 +135,15 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev,
|
|||||||
inb(dev->iobase + AIO12_8_STATUS_REG);
|
inb(dev->iobase + AIO12_8_STATUS_REG);
|
||||||
|
|
||||||
for (n = 0; n < insn->n; n++) {
|
for (n = 0; n < insn->n; n++) {
|
||||||
int timeout = 5;
|
|
||||||
|
|
||||||
/* Setup and start conversion */
|
/* Setup and start conversion */
|
||||||
outb(control, dev->iobase + AIO12_8_ADC_REG);
|
outb(control, dev->iobase + AIO12_8_ADC_REG);
|
||||||
|
|
||||||
/* Wait for conversion to complete */
|
/* Wait for conversion to complete */
|
||||||
do {
|
ret = comedi_timeout(dev, s, insn, aio_aio12_8_ai_eoc, 0);
|
||||||
val = inb(dev->iobase + AIO12_8_STATUS_REG);
|
if (ret) {
|
||||||
timeout--;
|
|
||||||
if (timeout == 0) {
|
|
||||||
dev_err(dev->class_dev, "ADC timeout\n");
|
dev_err(dev->class_dev, "ADC timeout\n");
|
||||||
return -ETIMEDOUT;
|
return ret;
|
||||||
}
|
}
|
||||||
} while (!(val & AIO12_8_STATUS_ADC_EOC));
|
|
||||||
|
|
||||||
data[n] = inw(dev->iobase + AIO12_8_ADC_REG) & s->maxdata;
|
data[n] = inw(dev->iobase + AIO12_8_ADC_REG) & s->maxdata;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user