summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-02-10 19:49:14 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-14 18:28:44 +0100
commite467bc37df212613b5b0fda9b262ffe548505986 (patch)
treedce9d45d34dbf5f11f1e6b1978ebfd1120edd630 /drivers
parentstaging: comedi: aio_aio12_8: use comedi_timeout() (diff)
downloadlinux-e467bc37df212613b5b0fda9b262ffe548505986.tar.xz
linux-e467bc37df212613b5b0fda9b262ffe548505986.zip
staging: comedi: cb_das16_cs: 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index 9a14e26e2416..549844cf2b35 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -101,6 +101,19 @@ static irqreturn_t das16cs_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
+static int das16cs_ai_eoc(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned long context)
+{
+ unsigned int status;
+
+ status = inw(dev->iobase + DAS16CS_MISC1);
+ if (status & 0x0080)
+ return 0;
+ return -EBUSY;
+}
+
static int das16cs_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -109,8 +122,8 @@ static int das16cs_ai_rinsn(struct comedi_device *dev,
int chan = CR_CHAN(insn->chanspec);
int range = CR_RANGE(insn->chanspec);
int aref = CR_AREF(insn->chanspec);
+ int ret;
int i;
- int to;
outw(chan, dev->iobase + DAS16CS_DIO_MUX);
@@ -138,15 +151,12 @@ static int das16cs_ai_rinsn(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) {
outw(0, dev->iobase + DAS16CS_ADC_DATA);
-#define TIMEOUT 1000
- for (to = 0; to < TIMEOUT; to++) {
- if (inw(dev->iobase + DAS16CS_MISC1) & 0x0080)
- break;
- }
- if (to == TIMEOUT) {
+ ret = comedi_timeout(dev, s, insn, das16cs_ai_eoc, 0);
+ if (ret) {
dev_dbg(dev->class_dev, "cb_das16_cs: ai timeout\n");
- return -ETIME;
+ return ret;
}
+
data[i] = inw(dev->iobase + DAS16CS_ADC_DATA);
}