From 83b4d991253dd764cfcb46fb10ef73bbff913e47 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Feb 2014 11:49:05 -0700 Subject: [PATCH] staging: comedi: ii_pci20kc: 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 --- drivers/staging/comedi/drivers/ii_pci20kc.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 8577778441fa..3558ab3b6e1f 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -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; -- 2.20.1