From: H Hartley Sweeten Date: Mon, 10 Feb 2014 18:49:04 +0000 (-0700) Subject: staging: comedi: das800: use comedi_timeout() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=90bc68ec9dec1e343ea7ac5e8ac8df5cd101947b;p=linux-beck.git staging: comedi: das800: use comedi_timeout() Use comedi_timeout() to wait for the analog input end-of-conversion. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 5af0a5764a8c..dbe94cea5905 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -556,15 +556,17 @@ static irqreturn_t das800_interrupt(int irq, void *d) return IRQ_HANDLED; } -static int das800_wait_for_conv(struct comedi_device *dev, int timeout) +static int das800_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 + DAS800_STATUS) & BUSY)) - return 0; - } - return -ETIME; + status = inb(dev->iobase + DAS800_STATUS); + if ((status & BUSY) == 0) + return 0; + return -EBUSY; } static int das800_ai_insn_read(struct comedi_device *dev, @@ -599,7 +601,7 @@ static int das800_ai_insn_read(struct comedi_device *dev, /* trigger conversion */ outb_p(0, dev->iobase + DAS800_MSB); - ret = das800_wait_for_conv(dev, 1000); + ret = comedi_timeout(dev, s, insn, das800_ai_eoc, 0); if (ret) return ret;