[PATCH 09/25] staging: comedi: das1800: introduce das1800_isadma_program()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce a helper function to program the ISA DMA controller. Program
the ISA DMA as described in Documentation/DMA-ISA-LPC.txt.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/das1800.c | 48 ++++++++++++++------------------
 1 file changed, 21 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index c8ad7dd..6df58cd 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -452,6 +452,19 @@ static const struct comedi_lrange range_ao_2 = {
 };
 */
 
+static void das1800_isadma_program(struct das1800_dma_desc *dma)
+{
+	unsigned long flags;
+
+	flags = claim_dma_lock();
+	clear_dma_ff(dma->chan);
+	set_dma_mode(dma->chan, DMA_MODE_READ);
+	set_dma_addr(dma->chan, dma->hw_addr);
+	set_dma_count(dma->chan, dma->size);
+	enable_dma(dma->chan);
+	release_dma_lock(flags);
+}
+
 static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
 					    uint16_t sample)
 {
@@ -571,12 +584,11 @@ static void das1800_handle_dma(struct comedi_device *dev,
 
 	flags = claim_dma_lock();
 	das1800_flush_dma_channel(dev, s, dma);
-	/*  re-enable  dma channel */
-	set_dma_addr(dma->chan, dma->hw_addr);
-	set_dma_count(dma->chan, dma->size);
-	enable_dma(dma->chan);
 	release_dma_lock(flags);
 
+	/* re-enable dma channel */
+	das1800_isadma_program(dma);
+
 	if (status & DMATC) {
 		/*  clear DMATC interrupt bit */
 		outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS);
@@ -998,8 +1010,6 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 {
 	struct das1800_private *devpriv = dev->private;
 	struct das1800_dma_desc *dma = &devpriv->dma_desc[0];
-	unsigned long lock_flags;
-	const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
 	unsigned int bytes;
 
 	if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0)
@@ -1011,29 +1021,14 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 	bytes = suggest_transfer_size(cmd);
 
 	dma->size = bytes;
-	lock_flags = claim_dma_lock();
-	disable_dma(dma->chan);
-	/* clear flip-flop to make sure 2-byte registers for
-	 * count and address get set correctly */
-	clear_dma_ff(dma->chan);
-	set_dma_addr(dma->chan, dma->hw_addr);
-	/*  set appropriate size of transfer */
-	set_dma_count(dma->chan, dma->size);
-	enable_dma(dma->chan);
-	/*  set up dual dma if appropriate */
-	if (dual_dma) {
+	das1800_isadma_program(dma);
+
+	/* set up dual dma if appropriate */
+	if (devpriv->irq_dma_bits & DMA_DUAL) {
 		dma = &devpriv->dma_desc[1];
 		dma->size = bytes;
-		disable_dma(dma->chan);
-		/* clear flip-flop to make sure 2-byte registers for
-		 * count and address get set correctly */
-		clear_dma_ff(dma->chan);
-		set_dma_addr(dma->chan, dma->hw_addr);
-		/*  set appropriate size of transfer */
-		set_dma_count(dma->chan, dma->size);
-		enable_dma(dma->chan);
+		das1800_isadma_program(dma);
 	}
-	release_dma_lock(lock_flags);
 }
 
 /* programs channel/gain list into card */
@@ -1299,7 +1294,6 @@ static int das1800_init_dma(struct comedi_device *dev,
 
 		flags = claim_dma_lock();
 		disable_dma(dma->chan);
-		set_dma_mode(dma->chan, DMA_MODE_READ);
 		release_dma_lock(flags);
 	}
 
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux