diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-02-10 19:49:15 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-14 18:28:44 +0100 |
commit | 06cb9ba887d07e80ac51d8a233d56e5fd39bc175 (patch) | |
tree | 6a5864d6c98904d43550efb8e9a2eba6741f41a2 /drivers | |
parent | staging: comedi: cb_das16_cs: use comedi_timeout() (diff) | |
download | linux-06cb9ba887d07e80ac51d8a233d56e5fd39bc175.tar.xz linux-06cb9ba887d07e80ac51d8a233d56e5fd39bc175.zip |
staging: comedi: cb_pcidas: use comedi_timeout()
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcidas.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 69fbda7e3bc2..7d068ebe0575 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -376,6 +376,20 @@ static inline unsigned int cal_enable_bits(struct comedi_device *dev) return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source); } +static int cb_pcidas_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + struct cb_pcidas_private *devpriv = dev->private; + unsigned int status; + + status = inw(devpriv->control_status + ADCMUX_CONT); + if (status & EOC) + return 0; + return -EBUSY; +} + static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -385,7 +399,8 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, unsigned int range = CR_RANGE(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); unsigned int bits; - int n, i; + int ret; + int n; /* enable calibration input if appropriate */ if (insn->chanspec & CR_ALT_SOURCE) { @@ -415,13 +430,9 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, outw(0, devpriv->adc_fifo + ADCDATA); /* wait for conversion to end */ - /* return -ETIMEDOUT if there is a timeout */ - for (i = 0; i < 10000; i++) { - if (inw(devpriv->control_status + ADCMUX_CONT) & EOC) - break; - } - if (i == 10000) - return -ETIMEDOUT; + ret = comedi_timeout(dev, s, insn, cb_pcidas_ai_eoc, 0); + if (ret) + return ret; /* read data */ data[n] = inw(devpriv->adc_fifo + ADCDATA); |