staging: comedi: adl_pci6208x: use comedi_timeout()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 10 Feb 2014 18:49:02 +0000 (11:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2014 17:28:43 +0000 (09:28 -0800)
Use comedi_timeout() to wait for the analog output 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/adl_pci6208.c

index 5c1413abc52de18ff6ab051c9e394a6b6038e690..921f6942dfce8e82833854c16ec35c6fa48077e4 100644 (file)
@@ -73,19 +73,17 @@ struct pci6208_private {
        unsigned int ao_readback[PCI6208_MAX_AO_CHANNELS];
 };
 
-static int pci6208_ao_wait_for_data_send(struct comedi_device *dev,
-                                        unsigned int timeout)
+static int pci6208_ao_eoc(struct comedi_device *dev,
+                         struct comedi_subdevice *s,
+                         struct comedi_insn *insn,
+                         unsigned long context)
 {
        unsigned int status;
 
-       while (timeout--) {
-               status = inw(dev->iobase + PCI6208_AO_STATUS);
-               if ((status & PCI6208_AO_STATUS_DATA_SEND) == 0)
-                       return 0;
-               udelay(1);
-       }
-
-       return -ETIME;
+       status = inw(dev->iobase + PCI6208_AO_STATUS);
+       if ((status & PCI6208_AO_STATUS_DATA_SEND) == 0)
+               return 0;
+       return -EBUSY;
 }
 
 static int pci6208_ao_insn_write(struct comedi_device *dev,
@@ -102,8 +100,8 @@ static int pci6208_ao_insn_write(struct comedi_device *dev,
        for (i = 0; i < insn->n; i++) {
                val = data[i];
 
-               /* D/A transfer rate is 2.2us, wait up to 10us */
-               ret = pci6208_ao_wait_for_data_send(dev, 10);
+               /* D/A transfer rate is 2.2us */
+               ret = comedi_timeout(dev, s, insn, pci6208_ao_eoc, 0);
                if (ret)
                        return ret;
 
This page took 0.025106 seconds and 5 git commands to generate.