staging: comedi: das08: 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>
This commit is contained in:
parent
6976a449cd
commit
c3ce086e15
@ -201,17 +201,29 @@ static const int *const das08_gainlists[] = {
|
|||||||
das08_pgm_gainlist,
|
das08_pgm_gainlist,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TIMEOUT 100000
|
static int das08_ai_eoc(struct comedi_device *dev,
|
||||||
|
struct comedi_subdevice *s,
|
||||||
|
struct comedi_insn *insn,
|
||||||
|
unsigned long context)
|
||||||
|
{
|
||||||
|
unsigned int status;
|
||||||
|
|
||||||
|
status = inb(dev->iobase + DAS08_STATUS);
|
||||||
|
if ((status & DAS08_EOC) == 0)
|
||||||
|
return 0;
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
static int das08_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 das08_board_struct *thisboard = comedi_board(dev);
|
const struct das08_board_struct *thisboard = comedi_board(dev);
|
||||||
struct das08_private_struct *devpriv = dev->private;
|
struct das08_private_struct *devpriv = dev->private;
|
||||||
int i, n;
|
int n;
|
||||||
int chan;
|
int chan;
|
||||||
int range;
|
int range;
|
||||||
int lsb, msb;
|
int lsb, msb;
|
||||||
|
int ret;
|
||||||
|
|
||||||
chan = CR_CHAN(insn->chanspec);
|
chan = CR_CHAN(insn->chanspec);
|
||||||
range = CR_RANGE(insn->chanspec);
|
range = CR_RANGE(insn->chanspec);
|
||||||
@ -244,14 +256,12 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||||||
/* trigger conversion */
|
/* trigger conversion */
|
||||||
outb_p(0, dev->iobase + DAS08_TRIG_12BIT);
|
outb_p(0, dev->iobase + DAS08_TRIG_12BIT);
|
||||||
|
|
||||||
for (i = 0; i < TIMEOUT; i++) {
|
ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0);
|
||||||
if (!(inb(dev->iobase + DAS08_STATUS) & DAS08_EOC))
|
if (ret) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == TIMEOUT) {
|
|
||||||
dev_err(dev->class_dev, "timeout\n");
|
dev_err(dev->class_dev, "timeout\n");
|
||||||
return -ETIME;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
msb = inb(dev->iobase + DAS08_MSB);
|
msb = inb(dev->iobase + DAS08_MSB);
|
||||||
lsb = inb(dev->iobase + DAS08_LSB);
|
lsb = inb(dev->iobase + DAS08_LSB);
|
||||||
if (thisboard->ai_encoding == das08_encode12) {
|
if (thisboard->ai_encoding == das08_encode12) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user