]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: ii_pci20kc: use comedi_timeout()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 10 Feb 2014 18:49:05 +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/ii_pci20kc.c

index 8577778441fa8cfa1f5af64f40f82e4cc7d0ee15..3558ab3b6e1f77456bf2e1a7d50a866bc5963e8e 100644 (file)
@@ -190,20 +190,18 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
        return insn->n;
 }
 
-static int ii20k_ai_wait_eoc(struct comedi_device *dev,
-                            struct comedi_subdevice *s,
-                            int timeout)
+static int ii20k_ai_eoc(struct comedi_device *dev,
+                       struct comedi_subdevice *s,
+                       struct comedi_insn *insn,
+                       unsigned long context)
 {
        void __iomem *iobase = ii20k_module_iobase(dev, s);
        unsigned char status;
 
-       do {
-               status = readb(iobase + II20K_AI_STATUS_REG);
-               if ((status & II20K_AI_STATUS_INT) == 0)
-                       return 0;
-       } while (timeout--);
-
-       return -ETIME;
+       status = readb(iobase + II20K_AI_STATUS_REG);
+       if ((status & II20K_AI_STATUS_INT) == 0)
+               return 0;
+       return -EBUSY;
 }
 
 static void ii20k_ai_setup(struct comedi_device *dev,
@@ -263,7 +261,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev,
                /* generate a software start convert signal */
                readb(iobase + II20K_AI_PACER_RESET_REG);
 
-               ret = ii20k_ai_wait_eoc(dev, s, 100);
+               ret = comedi_timeout(dev, s, insn, ii20k_ai_eoc, 0);
                if (ret)
                        return ret;