[PATCH 05/12] staging: comedi: ni_labpc_isadma: add labpc_have_dma_chan()

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

 



Add a static inline function to "ni_labpc_isadma.h" to test if a DMA
channel has been set-up, in which case `devpriv->dma_chan` will be
non-zero (where `devpriv` point to the private data for the comedi
device).  If the "ni_labpc_isadma" module is not being built, don't
bother checking `devpriv->dma_chan`; just return `false` as this may
help the compiler to optimize out some unreachable code.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_labpc_isadma.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h
index 144f4ba..3b022ea 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h
+++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h
@@ -9,11 +9,23 @@
 
 #if NI_LABPC_HAVE_ISA_DMA
 
+static inline bool labpc_have_dma_chan(struct comedi_device *dev)
+{
+	struct labpc_private *devpriv = dev->private;
+
+	return (bool)devpriv->dma_chan;
+}
+
 int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan);
 void labpc_free_dma_chan(struct comedi_device *dev);
 
 #else
 
+static inline bool labpc_have_dma_chan(struct comedi_device *dev)
+{
+	return false;
+}
+
 static inline int labpc_init_dma_chan(struct comedi_device *dev,
 				      unsigned int dma_chan)
 {
-- 
1.8.2.1

_______________________________________________
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