]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
staging: comedi: dt2811: use comedi_timeout()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 10 Feb 2014 18:49:20 +0000 (11:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2014 17:28:45 +0000 (09:28 -0800)
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>
drivers/staging/comedi/drivers/dt2811.c

index 4271903facd7b93314d6749b78ad84300c26bfad..ba7c2ba618e6463cc7367c823a8c80198133724d 100644 (file)
@@ -224,23 +224,32 @@ static const struct comedi_lrange *dac_range_types[] = {
        &range_unipolar5
 };
 
-#define DT2811_TIMEOUT 5
+static int dt2811_ai_eoc(struct comedi_device *dev,
+                        struct comedi_subdevice *s,
+                        struct comedi_insn *insn,
+                        unsigned long context)
+{
+       unsigned int status;
+
+       status = inb(dev->iobase + DT2811_ADCSR);
+       if ((status & DT2811_ADBUSY) == 0)
+               return 0;
+       return -EBUSY;
+}
 
 static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
                          struct comedi_insn *insn, unsigned int *data)
 {
        int chan = CR_CHAN(insn->chanspec);
-       int timeout = DT2811_TIMEOUT;
+       int ret;
        int i;
 
        for (i = 0; i < insn->n; i++) {
                outb(chan, dev->iobase + DT2811_ADGCR);
 
-               while (timeout
-                      && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
-                       timeout--;
-               if (!timeout)
-                       return -ETIME;
+               ret = comedi_timeout(dev, s, insn, dt2811_ai_eoc, 0);
+               if (ret)
+                       return ret;
 
                data[i] = inb(dev->iobase + DT2811_ADDATLO);
                data[i] |= inb(dev->iobase + DT2811_ADDATHI) << 8;