staging: comedi: pcl711: use comedi_timeout()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 10 Feb 2014 18:49:08 +0000 (11:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2014 17:28:44 +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/pcl711.c

index 659578881a4eacff3afd618ef4a2d740285267ba..7c03a5d17b1b1d963341499e78e05bd8fcd8f893 100644 (file)
@@ -253,18 +253,17 @@ static void pcl711_set_changain(struct comedi_device *dev,
        outb(mux | PCL711_MUX_CHAN(chan), dev->iobase + PCL711_MUX_REG);
 }
 
-static int pcl711_ai_wait_for_eoc(struct comedi_device *dev,
-                                 unsigned int timeout)
+static int pcl711_ai_eoc(struct comedi_device *dev,
+                        struct comedi_subdevice *s,
+                        struct comedi_insn *insn,
+                        unsigned long context)
 {
-       unsigned int msb;
+       unsigned int status;
 
-       while (timeout--) {
-               msb = inb(dev->iobase + PCL711_AI_MSB_REG);
-               if ((msb & PCL711_AI_MSB_DRDY) == 0)
-                       return 0;
-               udelay(1);
-       }
-       return -ETIME;
+       status = inb(dev->iobase + PCL711_AI_MSB_REG);
+       if ((status & PCL711_AI_MSB_DRDY) == 0)
+               return 0;
+       return -EBUSY;
 }
 
 static int pcl711_ai_insn_read(struct comedi_device *dev,
@@ -282,7 +281,7 @@ static int pcl711_ai_insn_read(struct comedi_device *dev,
        for (i = 0; i < insn->n; i++) {
                outb(PCL711_SOFTTRIG, dev->iobase + PCL711_SOFTTRIG_REG);
 
-               ret = pcl711_ai_wait_for_eoc(dev, 100);
+               ret = comedi_timeout(dev, s, insn, pcl711_ai_eoc, 0);
                if (ret)
                        return ret;