staging: comedi: ni_labpc: migrate DMA status handling
authorIan Abbott <abbotti@mev.co.uk>
Fri, 28 Jun 2013 16:09:26 +0000 (17:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 21:27:52 +0000 (14:27 -0700)
Migrate the code for checking and handling the interrupt status handling
for ISA DMA transfers into new a new function
`labpc_handle_dma_status()` in the "ni_labpc_isadma" module.  Provide a
dummy inline function in "ni_labpc_isadma.h" if the "ni_labpc_isadma"
module is not being built.

The static function `handle_isa_dma()` also needs to move across to the
new module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc_isadma.c
drivers/staging/comedi/drivers/ni_labpc_isadma.h

index 818a8abe208ca7017060d910fbb1bfd9dbee1619..57985a24dda4609c8125ef9bc1bcacfcb14e01a7 100644 (file)
@@ -905,20 +905,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-#ifdef CONFIG_ISA_DMA_API
-static void handle_isa_dma(struct comedi_device *dev)
-{
-       struct labpc_private *devpriv = dev->private;
-
-       labpc_drain_dma(dev);
-
-       enable_dma(devpriv->dma_chan);
-
-       /*  clear dma tc interrupt */
-       devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG);
-}
-#endif
-
 /* read all available samples from ai fifo */
 static int labpc_drain_fifo(struct comedi_device *dev)
 {
@@ -1003,18 +989,9 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
                return IRQ_HANDLED;
        }
 
-#ifdef CONFIG_ISA_DMA_API
-       if (devpriv->current_transfer == isa_dma_transfer) {
-               /*
-                * if a dma terminal count of external stop trigger
-                * has occurred
-                */
-               if (devpriv->stat1 & STAT1_GATA0 ||
-                   (board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1)) {
-                       handle_isa_dma(dev);
-               }
-       } else
-#endif
+       if (devpriv->current_transfer == isa_dma_transfer)
+               labpc_handle_dma_status(dev);
+       else
                labpc_drain_fifo(dev);
 
        if (devpriv->stat1 & STAT1_CNTINT) {
index c4bfecc07b6374facc13d34e21b094f7f927835c..2149596830afdddb4d851731419863605150c416 100644 (file)
@@ -137,6 +137,33 @@ void labpc_drain_dma(struct comedi_device *dev)
 }
 EXPORT_SYMBOL_GPL(labpc_drain_dma);
 
+static void handle_isa_dma(struct comedi_device *dev)
+{
+       struct labpc_private *devpriv = dev->private;
+
+       labpc_drain_dma(dev);
+
+       enable_dma(devpriv->dma_chan);
+
+       /* clear dma tc interrupt */
+       devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG);
+}
+
+void labpc_handle_dma_status(struct comedi_device *dev)
+{
+       const struct labpc_boardinfo *board = comedi_board(dev);
+       struct labpc_private *devpriv = dev->private;
+
+       /*
+        * if a dma terminal count of external stop trigger
+        * has occurred
+        */
+       if (devpriv->stat1 & STAT1_GATA0 ||
+           (board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1))
+               handle_isa_dma(dev);
+}
+EXPORT_SYMBOL_GPL(labpc_handle_dma_status);
+
 int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
 {
        struct labpc_private *devpriv = dev->private;
index 1f322f2bc2d9e9abe9a775a944fb5e2d8eb7548f..771af4bd5a7623859166661e53501627f8b5f5ad 100644 (file)
@@ -20,6 +20,7 @@ int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan);
 void labpc_free_dma_chan(struct comedi_device *dev);
 void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s);
 void labpc_drain_dma(struct comedi_device *dev);
+void labpc_handle_dma_status(struct comedi_device *dev);
 
 #else
 
@@ -47,6 +48,10 @@ static inline void labpc_drain_dma(struct comedi_device *dev)
 {
 }
 
+static inline void labpc_handle_dma_status(struct comedi_device *dev)
+{
+}
+
 #endif
 
 #endif /* _NI_LABPC_ISADMA_H */