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

staging: comedi: amplc_pci230: 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 5cc0387c
...@@ -799,19 +799,29 @@ static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct) ...@@ -799,19 +799,29 @@ static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
/* Counter ct, 8254 mode 1, initial count not written. */ /* Counter ct, 8254 mode 1, initial count not written. */
} }
/* static int pci230_ai_eoc(struct comedi_device *dev,
* COMEDI_SUBD_AI instruction; struct comedi_subdevice *s,
*/ struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inw(dev->iobase + PCI230_ADCCON);
if ((status & PCI230_ADC_FIFO_EMPTY) == 0)
return 0;
return -EBUSY;
}
static int pci230_ai_rinsn(struct comedi_device *dev, static int pci230_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn, struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct pci230_private *devpriv = dev->private; struct pci230_private *devpriv = dev->private;
unsigned int n, i; unsigned int n;
unsigned int chan, range, aref; unsigned int chan, range, aref;
unsigned int gainshift; unsigned int gainshift;
unsigned int status;
unsigned short adccon, adcen; unsigned short adccon, adcen;
int ret;
/* Unpack channel and range. */ /* Unpack channel and range. */
chan = CR_CHAN(insn->chanspec); chan = CR_CHAN(insn->chanspec);
...@@ -883,17 +893,11 @@ static int pci230_ai_rinsn(struct comedi_device *dev, ...@@ -883,17 +893,11 @@ static int pci230_ai_rinsn(struct comedi_device *dev,
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2, i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2,
I8254_MODE1); I8254_MODE1);
#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, pci230_ai_eoc, 0);
status = inw(dev->iobase + PCI230_ADCCON); if (ret) {
if (!(status & PCI230_ADC_FIFO_EMPTY))
break;
udelay(1);
}
if (i == TIMEOUT) {
dev_err(dev->class_dev, "timeout\n"); dev_err(dev->class_dev, "timeout\n");
return -ETIMEDOUT; return ret;
} }
/* read data */ /* read data */
......
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