]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: ni_labpc: migrate labpc_drain_dma()
authorIan Abbott <abbotti@mev.co.uk>
Fri, 28 Jun 2013 16:09:25 +0000 (17:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 21:27:52 +0000 (14:27 -0700)
Move `labpc_drain_dma()` into the "ni_labpc_isadma" module.  Provide a
dummy inline function in "ni_labpc_isadma.h" if the module is not being
built.

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 e1b073f746fe037c3ee57d4b9b7a23d0933fe070..818a8abe208ca7017060d910fbb1bfd9dbee1619 100644 (file)
@@ -906,60 +906,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 
 #ifdef CONFIG_ISA_DMA_API
-static void labpc_drain_dma(struct comedi_device *dev)
-{
-       struct labpc_private *devpriv = dev->private;
-       struct comedi_subdevice *s = dev->read_subdev;
-       struct comedi_async *async = s->async;
-       int status;
-       unsigned long flags;
-       unsigned int max_points, num_points, residue, leftover;
-       int i;
-
-       status = devpriv->stat1;
-
-       flags = claim_dma_lock();
-       disable_dma(devpriv->dma_chan);
-       /* clear flip-flop to make sure 2-byte registers for
-        * count and address get set correctly */
-       clear_dma_ff(devpriv->dma_chan);
-
-       /*  figure out how many points to read */
-       max_points = devpriv->dma_transfer_size / sample_size;
-       /* residue is the number of points left to be done on the dma
-        * transfer.  It should always be zero at this point unless
-        * the stop_src is set to external triggering.
-        */
-       residue = get_dma_residue(devpriv->dma_chan) / sample_size;
-       num_points = max_points - residue;
-       if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT)
-               num_points = devpriv->count;
-
-       /*  figure out how many points will be stored next time */
-       leftover = 0;
-       if (async->cmd.stop_src != TRIG_COUNT) {
-               leftover = devpriv->dma_transfer_size / sample_size;
-       } else if (devpriv->count > num_points) {
-               leftover = devpriv->count - num_points;
-               if (leftover > max_points)
-                       leftover = max_points;
-       }
-
-       /* write data to comedi buffer */
-       for (i = 0; i < num_points; i++)
-               cfc_write_to_buffer(s, devpriv->dma_buffer[i]);
-
-       if (async->cmd.stop_src == TRIG_COUNT)
-               devpriv->count -= num_points;
-
-       /*  set address and count for next transfer */
-       set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
-       set_dma_count(devpriv->dma_chan, leftover * sample_size);
-       release_dma_lock(flags);
-
-       async->events |= COMEDI_CB_BLOCK;
-}
-
 static void handle_isa_dma(struct comedi_device *dev)
 {
        struct labpc_private *devpriv = dev->private;
@@ -1009,12 +955,10 @@ static int labpc_drain_fifo(struct comedi_device *dev)
  * when acquisition is terminated by stop_src == TRIG_EXT). */
 static void labpc_drain_dregs(struct comedi_device *dev)
 {
-#ifdef CONFIG_ISA_DMA_API
        struct labpc_private *devpriv = dev->private;
 
        if (devpriv->current_transfer == isa_dma_transfer)
                labpc_drain_dma(dev);
-#endif
 
        labpc_drain_fifo(dev);
 }
index dba2be36c48d742b7be453a06987014b9d3e101b..c4bfecc07b6374facc13d34e21b094f7f927835c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <asm/dma.h>
 
+#include "comedi_fc.h"
 #include "ni_labpc.h"
 #include "ni_labpc_regs.h"
 #include "ni_labpc_isadma.h"
@@ -81,6 +82,61 @@ void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 EXPORT_SYMBOL_GPL(labpc_setup_dma);
 
+void labpc_drain_dma(struct comedi_device *dev)
+{
+       struct labpc_private *devpriv = dev->private;
+       struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_async *async = s->async;
+       int status;
+       unsigned long flags;
+       unsigned int max_points, num_points, residue, leftover;
+       int i;
+
+       status = devpriv->stat1;
+
+       flags = claim_dma_lock();
+       disable_dma(devpriv->dma_chan);
+       /* clear flip-flop to make sure 2-byte registers for
+        * count and address get set correctly */
+       clear_dma_ff(devpriv->dma_chan);
+
+       /* figure out how many points to read */
+       max_points = devpriv->dma_transfer_size / sample_size;
+       /* residue is the number of points left to be done on the dma
+        * transfer.  It should always be zero at this point unless
+        * the stop_src is set to external triggering.
+        */
+       residue = get_dma_residue(devpriv->dma_chan) / sample_size;
+       num_points = max_points - residue;
+       if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT)
+               num_points = devpriv->count;
+
+       /* figure out how many points will be stored next time */
+       leftover = 0;
+       if (async->cmd.stop_src != TRIG_COUNT) {
+               leftover = devpriv->dma_transfer_size / sample_size;
+       } else if (devpriv->count > num_points) {
+               leftover = devpriv->count - num_points;
+               if (leftover > max_points)
+                       leftover = max_points;
+       }
+
+       /* write data to comedi buffer */
+       for (i = 0; i < num_points; i++)
+               cfc_write_to_buffer(s, devpriv->dma_buffer[i]);
+
+       if (async->cmd.stop_src == TRIG_COUNT)
+               devpriv->count -= num_points;
+
+       /* set address and count for next transfer */
+       set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
+       set_dma_count(devpriv->dma_chan, leftover * sample_size);
+       release_dma_lock(flags);
+
+       async->events |= COMEDI_CB_BLOCK;
+}
+EXPORT_SYMBOL_GPL(labpc_drain_dma);
+
 int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
 {
        struct labpc_private *devpriv = dev->private;
index c721f57daf0c23e58a7b5fa611e69d9a47eb136f..1f322f2bc2d9e9abe9a775a944fb5e2d8eb7548f 100644 (file)
@@ -19,6 +19,7 @@ static inline bool labpc_have_dma_chan(struct comedi_device *dev)
 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);
 
 #else
 
@@ -42,6 +43,10 @@ static inline void labpc_setup_dma(struct comedi_device *dev,
 {
 }
 
+static inline void labpc_drain_dma(struct comedi_device *dev)
+{
+}
+
 #endif
 
 #endif /* _NI_LABPC_ISADMA_H */