staging: comedi: dyna_pci10xx: use comedi_timeout()
Use comedi_timeout() to wait for the analog input end-of-conversion. Also, remove some unnecessary comments. 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>
This commit is contained in:
parent
0883fcab44
commit
443e6d02c8
1 changed files with 24 additions and 16 deletions
|
@ -57,18 +57,27 @@ struct dyna_pci10xx_private {
|
||||||
unsigned long BADR3;
|
unsigned long BADR3;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
static int dyna_pci10xx_ai_eoc(struct comedi_device *dev,
|
||||||
/************************** READ WRITE FUNCTIONS ******************************/
|
struct comedi_subdevice *s,
|
||||||
/******************************************************************************/
|
struct comedi_insn *insn,
|
||||||
|
unsigned long context)
|
||||||
|
{
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
|
status = inw_p(dev->iobase);
|
||||||
|
if (status & (1 << 15))
|
||||||
|
return 0;
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
/* analog input callback */
|
|
||||||
static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
|
static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
|
||||||
struct comedi_subdevice *s,
|
struct comedi_subdevice *s,
|
||||||
struct comedi_insn *insn, unsigned int *data)
|
struct comedi_insn *insn, unsigned int *data)
|
||||||
{
|
{
|
||||||
struct dyna_pci10xx_private *devpriv = dev->private;
|
struct dyna_pci10xx_private *devpriv = dev->private;
|
||||||
int n, counter;
|
int n;
|
||||||
u16 d = 0;
|
u16 d = 0;
|
||||||
|
int ret = 0;
|
||||||
unsigned int chan, range;
|
unsigned int chan, range;
|
||||||
|
|
||||||
/* get the channel number and range */
|
/* get the channel number and range */
|
||||||
|
@ -82,18 +91,17 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
|
||||||
smp_mb();
|
smp_mb();
|
||||||
outw_p(0x0000 + range + chan, dev->iobase + 2);
|
outw_p(0x0000 + range + chan, dev->iobase + 2);
|
||||||
udelay(10);
|
udelay(10);
|
||||||
/* read data */
|
|
||||||
for (counter = 0; counter < READ_TIMEOUT; counter++) {
|
|
||||||
d = inw_p(dev->iobase);
|
|
||||||
|
|
||||||
/* check if read is successful if the EOC bit is set */
|
ret = comedi_timeout(dev, s, insn, dyna_pci10xx_ai_eoc, 0);
|
||||||
if (d & (1 << 15))
|
if (ret) {
|
||||||
goto conv_finish;
|
data[n] = 0;
|
||||||
|
dev_dbg(dev->class_dev,
|
||||||
|
"timeout reading analog input\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
data[n] = 0;
|
|
||||||
dev_dbg(dev->class_dev, "timeout reading analog input\n");
|
/* read data */
|
||||||
continue;
|
d = inw_p(dev->iobase);
|
||||||
conv_finish:
|
|
||||||
/* mask the first 4 bits - EOC bits */
|
/* mask the first 4 bits - EOC bits */
|
||||||
d &= 0x0FFF;
|
d &= 0x0FFF;
|
||||||
data[n] = d;
|
data[n] = d;
|
||||||
|
@ -101,7 +109,7 @@ conv_finish:
|
||||||
mutex_unlock(&devpriv->mutex);
|
mutex_unlock(&devpriv->mutex);
|
||||||
|
|
||||||
/* return the number of samples read/written */
|
/* return the number of samples read/written */
|
||||||
return n;
|
return ret ? ret : n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* analog output callback */
|
/* analog output callback */
|
||||||
|
|
Loading…
Add table
Reference in a new issue