[PATCH 098/108] staging: comedi: addi_apci_3120: move apci3120_setup_dma() to driver

H Hartley Sweeten hsweeten at visionengravers.com
Tue Nov 4 17:55:22 UTC 2014


Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 .../comedi/drivers/addi-data/hwdrv_apci3120.c      | 51 ----------------------
 drivers/staging/comedi/drivers/addi_apci_3120.c    | 51 ++++++++++++++++++++++
 2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index a241368..771ac87 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -26,57 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev,
 	return 0;
 }
 
-static void apci3120_setup_dma(struct comedi_device *dev,
-			       struct comedi_subdevice *s)
-{
-	struct apci3120_private *devpriv = dev->private;
-	struct comedi_cmd *cmd = &s->async->cmd;
-	struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0];
-	struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1];
-	unsigned int dmalen0 = dmabuf0->size;
-	unsigned int dmalen1 = dmabuf1->size;
-	unsigned int scan_bytes;
-
-	scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg);
-
-	if (cmd->stop_src == TRIG_COUNT) {
-		/*
-		 * Must we fill full first buffer? And must we fill
-		 * full second buffer when first is once filled?
-		 */
-		if (dmalen0 > (cmd->stop_arg * scan_bytes))
-			dmalen0 = cmd->stop_arg * scan_bytes;
-		else if (dmalen1 > (cmd->stop_arg * scan_bytes - dmalen0))
-			dmalen1 = cmd->stop_arg * scan_bytes - dmalen0;
-	}
-
-	if (cmd->flags & CMDF_WAKE_EOS) {
-		/* don't we want wake up every scan? */
-		if (dmalen0 > scan_bytes) {
-			dmalen0 = scan_bytes;
-			if (cmd->scan_end_arg & 1)
-				dmalen0 += 2;
-		}
-		if (dmalen1 > scan_bytes) {
-			dmalen1 = scan_bytes;
-			if (cmd->scan_end_arg & 1)
-				dmalen1 -= 2;
-			if (dmalen1 < 4)
-				dmalen1 = 4;
-		}
-	} else {
-		/* isn't output buff smaller that our DMA buff? */
-		if (dmalen0 > s->async->prealloc_bufsz)
-			dmalen0 = s->async->prealloc_bufsz;
-		if (dmalen1 > s->async->prealloc_bufsz)
-			dmalen1 = s->async->prealloc_bufsz;
-	}
-	dmabuf0->use_size = dmalen0;
-	dmabuf1->use_size = dmalen1;
-
-	apci3120_init_dma(dev, dmabuf0);
-}
-
 static int apci3120_ai_cmd(struct comedi_device *dev,
 			   struct comedi_subdevice *s)
 {
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c
index d66e910..b5ac5b8 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -209,6 +209,57 @@ static void apci3120_init_dma(struct comedi_device *dev,
 	     devpriv->addon + APCI3120_ADDON_CTRL_REG);
 }
 
+static void apci3120_setup_dma(struct comedi_device *dev,
+			       struct comedi_subdevice *s)
+{
+	struct apci3120_private *devpriv = dev->private;
+	struct comedi_cmd *cmd = &s->async->cmd;
+	struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0];
+	struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1];
+	unsigned int dmalen0 = dmabuf0->size;
+	unsigned int dmalen1 = dmabuf1->size;
+	unsigned int scan_bytes;
+
+	scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg);
+
+	if (cmd->stop_src == TRIG_COUNT) {
+		/*
+		 * Must we fill full first buffer? And must we fill
+		 * full second buffer when first is once filled?
+		 */
+		if (dmalen0 > (cmd->stop_arg * scan_bytes))
+			dmalen0 = cmd->stop_arg * scan_bytes;
+		else if (dmalen1 > (cmd->stop_arg * scan_bytes - dmalen0))
+			dmalen1 = cmd->stop_arg * scan_bytes - dmalen0;
+	}
+
+	if (cmd->flags & CMDF_WAKE_EOS) {
+		/* don't we want wake up every scan? */
+		if (dmalen0 > scan_bytes) {
+			dmalen0 = scan_bytes;
+			if (cmd->scan_end_arg & 1)
+				dmalen0 += 2;
+		}
+		if (dmalen1 > scan_bytes) {
+			dmalen1 = scan_bytes;
+			if (cmd->scan_end_arg & 1)
+				dmalen1 -= 2;
+			if (dmalen1 < 4)
+				dmalen1 = 4;
+		}
+	} else {
+		/* isn't output buff smaller that our DMA buff? */
+		if (dmalen0 > s->async->prealloc_bufsz)
+			dmalen0 = s->async->prealloc_bufsz;
+		if (dmalen1 > s->async->prealloc_bufsz)
+			dmalen1 = s->async->prealloc_bufsz;
+	}
+	dmabuf0->use_size = dmalen0;
+	dmabuf1->use_size = dmalen1;
+
+	apci3120_init_dma(dev, dmabuf0);
+}
+
 /*
  * There are three timers on the board. They all use the same base
  * clock with a fixed prescaler for each timer. The base clock used
-- 
2.0.3



More information about the devel mailing list