According to the manual, the A/D FIFO needs to be reset and cleared after a conversion failure. For aesthetics, factor the code that does this out of daq700_ai_config() and use the new helper function when a conversion times out. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/ni_daq_700.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index bde5996..295b14a 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -162,6 +162,12 @@ static void daq700_ai_start_conv(struct comedi_device *dev) 0, I8254_MODE1 | I8254_BINARY); /* OUT0 high */ } +static void daq700_ai_flush_fifo(struct comedi_device *dev) +{ + outb(DAQ700_AI_CLR_FIFO, dev->iobase + DAQ700_AI_CLR_REG); + inw(dev->iobase + DAQ700_AI_FIFO_REG); +} + static int daq700_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -216,8 +222,10 @@ static int daq700_ai_rinsn(struct comedi_device *dev, /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, daq700_ai_eoc, 0); - if (ret) + if (ret) { + daq700_ai_flush_fifo(dev); return ret; + } /* read data */ d = inw(dev->iobase + DAQ700_AI_FIFO_REG); @@ -253,8 +261,7 @@ static void daq700_ai_config(struct comedi_device *dev, i8254_set_mode(iobase + DAQ700_TIMER_BASE, 0, 0, I8254_MODE1 | I8254_BINARY); /* OUT0 high */ outb(DAQ700_TIC_CLR_INT, iobase + DAQ700_TIC_REG); - outb(DAQ700_AI_CLR_FIFO, iobase + DAQ700_AI_CLR_REG); - inw(iobase + DAQ700_AI_FIFO_REG); + daq700_ai_flush_fifo(dev); } static int daq700_auto_attach(struct comedi_device *dev, -- 1.9.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel