diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-02-10 11:49:43 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-14 09:28:46 -0800 |
commit | 82c7e864a0fe0a2eb381f678e34909595eac9be8 (patch) | |
tree | 80581c81ca24d6d2c41ecc54cc2bc5ecbeca7167 /drivers | |
parent | 1d6f4af9090021eb7a1074d30ebd991d43a639c6 (diff) | |
download | linux-82c7e864a0fe0a2eb381f678e34909595eac9be8.tar.gz linux-82c7e864a0fe0a2eb381f678e34909595eac9be8.tar.bz2 linux-82c7e864a0fe0a2eb381f678e34909595eac9be8.zip |
staging: comedi: dt2814: 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/dt2814.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index abad6e49c1c1..3794b7e52091 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -66,26 +66,35 @@ struct dt2814_private { #define DT2814_TIMEOUT 10 #define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */ +static int dt2814_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inb(dev->iobase + DT2814_CSR); + if (status & DT2814_FINISH) + return 0; + return -EBUSY; +} + static int dt2814_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int n, i, hi, lo; + int n, hi, lo; int chan; - int status = 0; + int ret; for (n = 0; n < insn->n; n++) { chan = CR_CHAN(insn->chanspec); outb(chan, dev->iobase + DT2814_CSR); - for (i = 0; i < DT2814_TIMEOUT; i++) { - status = inb(dev->iobase + DT2814_CSR); - udelay(10); - if (status & DT2814_FINISH) - break; - } - if (i >= DT2814_TIMEOUT) - return -ETIMEDOUT; + + ret = comedi_timeout(dev, s, insn, dt2814_ai_eoc, 0); + if (ret) + return ret; hi = inb(dev->iobase + DT2814_DATA); lo = inb(dev->iobase + DT2814_DATA); |