summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-04 10:54:11 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-07 09:33:59 -0800
commitd0bb66aa082c23741e85df459f7444f86cd86792 (patch)
tree6c201bb4cecc73c80effee027e7a17de33f0c0c1
parentea0bb9d221d14b622dedeaa10bd5f6ac525e6efd (diff)
staging: comedi: addi_apci_3120: introduce apci3120_ai_reset_fifo()
A dummy read of APCI3120_TIMER_MODE_REG resets the analog input FIFO. Introduce a helper function to clarify this. It's not necessary to do a dummy read of the FIFO (base + 0) before reseting it. Remove the unnecessary dummy reads. The APCI3120_TIMER_MODE_REG is a 16-bit register. This fixes a couple 8-bit reads. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c30
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_3120.c6
2 files changed, 13 insertions, 23 deletions
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 44a3fcd19b7f..0673e4fbc9b1 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -84,8 +84,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
#define APCI3120_RD_STATUS 0x02
#define APCI3120_RD_FIFO 0x00
-#define APCI3120_RESET_FIFO 0x0c
-
/* nWrMode_Select */
#define APCI3120_ENABLE_SCAN 0x8
#define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN)
@@ -261,11 +259,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
switch (us_TmpValue) {
case APCI3120_EOC_MODE:
-
- /*
- * Testing the interrupt flag and set the EOC bit Clears the FIFO
- */
- inw(dev->iobase + APCI3120_RESET_FIFO);
+ apci3120_ai_reset_fifo(dev);
/* Initialize the sequence array */
if (!apci3120_setup_chan_list(dev, s, 1,
@@ -321,16 +315,13 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
us_TmpValue = inw(dev->iobase + 0);
*data = us_TmpValue;
- inw(dev->iobase + APCI3120_RESET_FIFO);
+ apci3120_ai_reset_fifo(dev);
}
break;
case APCI3120_EOS_MODE:
-
- inw(dev->iobase + 0);
- /* Clears the FIFO */
- inw(dev->iobase + APCI3120_RESET_FIFO);
+ apci3120_ai_reset_fifo(dev);
if (!apci3120_setup_chan_list(dev, s,
devpriv->ui_AiNbrofChannels,
@@ -430,8 +421,7 @@ static int apci3120_reset(struct comedi_device *dev)
devpriv->ctrl = 0;
outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG);
- inw(dev->iobase + 0); /* make a dummy read */
- inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */
+ apci3120_ai_reset_fifo(dev);
inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */
return 0;
@@ -461,8 +451,8 @@ static int apci3120_cancel(struct comedi_device *dev,
/* DISABLE_ALL_INTERRUPT */
outb(APCI3120_DISABLE_ALL_INTERRUPT,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
- /* Flush FIFO */
- inb(dev->iobase + APCI3120_RESET_FIFO);
+
+ apci3120_ai_reset_fifo(dev);
inw(dev->iobase + APCI3120_RD_STATUS);
devpriv->ui_DmaActualBuffer = 0;
@@ -559,9 +549,6 @@ static int apci3120_cyclic_ai(int mode,
unsigned int dmalen1 = 0;
unsigned int divisor0;
- /* Resets the FIFO */
- inb(dev->iobase + APCI3120_RESET_FIFO);
-
devpriv->ai_running = 1;
/* clear software registers */
@@ -572,10 +559,7 @@ static int apci3120_cyclic_ai(int mode,
outl(APCI3120_CLEAR_WRITE_TC_INT,
devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR);
- /* Resets the FIFO */
- /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */
- inb(dev->iobase + APCI3120_RESET_FIFO);
- /* END JK 07.05.04: Comparison between WIN32 and Linux driver */
+ apci3120_ai_reset_fifo(dev);
devpriv->ui_DmaActualBuffer = 0;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c
index 45add7603d1b..8dfee45a0576 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -242,6 +242,12 @@ static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable)
outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG);
}
+static void apci3120_ai_reset_fifo(struct comedi_device *dev)
+{
+ /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */
+ inw(dev->iobase + APCI3120_TIMER_MODE_REG);
+}
+
#include "addi-data/hwdrv_apci3120.c"
static void apci3120_dma_alloc(struct comedi_device *dev)