Commit 96ed0850 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: cb_pcidas64: use comedi_timeout()

Use comedi_timeout() to wait for the analog input end-of-conversion.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06cb9ba8
...@@ -1664,15 +1664,36 @@ static void i2c_write(struct comedi_device *dev, unsigned int address, ...@@ -1664,15 +1664,36 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
i2c_stop(dev); i2c_stop(dev);
} }
static int cb_pcidas64_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
const struct pcidas64_board *thisboard = comedi_board(dev);
struct pcidas64_private *devpriv = dev->private;
unsigned int status;
status = readw(devpriv->main_iobase + HW_STATUS_REG);
if (thisboard->layout == LAYOUT_4020) {
status = readw(devpriv->main_iobase + ADC_WRITE_PNTR_REG);
if (status)
return 0;
} else {
if (pipe_full_bits(status))
return 0;
}
return -EBUSY;
}
static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct pcidas64_board *thisboard = comedi_board(dev); const struct pcidas64_board *thisboard = comedi_board(dev);
struct pcidas64_private *devpriv = dev->private; struct pcidas64_private *devpriv = dev->private;
unsigned int bits = 0, n, i; unsigned int bits = 0, n;
unsigned int channel, range, aref; unsigned int channel, range, aref;
unsigned long flags; unsigned long flags;
static const int timeout = 100; int ret;
channel = CR_CHAN(insn->chanspec); channel = CR_CHAN(insn->chanspec);
range = CR_RANGE(insn->chanspec); range = CR_RANGE(insn->chanspec);
...@@ -1770,23 +1791,12 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -1770,23 +1791,12 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->main_iobase + ADC_CONVERT_REG); devpriv->main_iobase + ADC_CONVERT_REG);
/* wait for data */ /* wait for data */
for (i = 0; i < timeout; i++) { ret = comedi_timeout(dev, s, insn, cb_pcidas64_ai_eoc, 0);
bits = readw(devpriv->main_iobase + HW_STATUS_REG); if (ret) {
if (thisboard->layout == LAYOUT_4020) {
if (readw(devpriv->main_iobase +
ADC_WRITE_PNTR_REG))
break;
} else {
if (pipe_full_bits(bits))
break;
}
udelay(1);
}
if (i == timeout) {
comedi_error(dev, " analog input read insn timed out"); comedi_error(dev, " analog input read insn timed out");
dev_info(dev->class_dev, "status 0x%x\n", bits); return ret;
return -ETIME;
} }
if (thisboard->layout == LAYOUT_4020) if (thisboard->layout == LAYOUT_4020)
data[n] = readl(devpriv->dio_counter_iobase + data[n] = readl(devpriv->dio_counter_iobase +
ADC_FIFO_REG) & 0xffff; ADC_FIFO_REG) & 0xffff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment