staging: comedi: pcmad: use comedi_timeout()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 10 Feb 2014 18:49:09 +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/pcmad.c

index fe482fdd512ed32f94af0987b236b2da28d62a57..87c61d9b11dae2544090f5c44b2fe1e7013d4e49 100644 (file)
@@ -61,18 +61,17 @@ static const struct pcmad_board_struct pcmad_boards[] = {
        },
 };
 
-#define TIMEOUT        100
-
-static int pcmad_ai_wait_for_eoc(struct comedi_device *dev,
-                                int timeout)
+static int pcmad_ai_eoc(struct comedi_device *dev,
+                       struct comedi_subdevice *s,
+                       struct comedi_insn *insn,
+                       unsigned long context)
 {
-       int i;
+       unsigned int status;
 
-       for (i = 0; i < timeout; i++) {
-               if ((inb(dev->iobase + PCMAD_STATUS) & 0x3) == 0x3)
-                       return 0;
-       }
-       return -ETIME;
+       status = inb(dev->iobase + PCMAD_STATUS);
+       if ((status & 0x3) == 0x3)
+               return 0;
+       return -EBUSY;
 }
 
 static int pcmad_ai_insn_read(struct comedi_device *dev,
@@ -89,7 +88,7 @@ static int pcmad_ai_insn_read(struct comedi_device *dev,
        for (i = 0; i < insn->n; i++) {
                outb(chan, dev->iobase + PCMAD_CONVERT);
 
-               ret = pcmad_ai_wait_for_eoc(dev, TIMEOUT);
+               ret = comedi_timeout(dev, s, insn, pcmad_ai_eoc, 0);
                if (ret)
                        return ret;
 
This page took 0.026022 seconds and 5 git commands to generate.