made comedi_spinlock functions do some type checking for standard linux and rtlinux...
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 3 Apr 2001 23:45:56 +0000 (23:45 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 3 Apr 2001 23:45:56 +0000 (23:45 +0000)
include/linux/comedi_rt.h

index 41d9c9223272c4b482b7618110b06b3e018e59da..d420817096b631fe7b9b88a8861029ea20ad37ba 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/config.h>
 #include <linux/malloc.h>
 #include <linux/errno.h>
+#include <linux/spinlock.h>
 
 #ifdef CONFIG_COMEDI_RT
 
@@ -69,31 +70,50 @@ void comedi_rt_pend_wakeup(wait_queue_head_t *q);
 #endif
 
 
-// define a spin_lock_irqsave function that will work with rt or without
+/* Define a spin_lock_irqsave function that will work with rt or without.
+ * Use inline functions instead of just macros to enforce some type checking.
+ */
+#define comedi_spin_lock_irqsave(lock_ptr, flags) \
+       (flags = __comedi_spin_lock_irqsave(lock_ptr))
+
+static inline unsigned long __comedi_spin_lock_irqsave(spinlock_t *lock_ptr)
+{
+       unsigned long flags;
+
+#if defined(CONFIG_COMEDI_RTAI)
+       flags = rt_spin_lock_irqsave(lock_ptr);
+
+#elif defined(CONFIG_COMEDI_RTL)
+       rtl_spin_lock_irqsave(lock_ptr, flags);
+
+#elif defined(CONFIG_COMEDI_RTL_V1)
+       rtl_spin_lock_irqsave(lock_ptr, flags);
+
+#else
+       spin_lock_irqsave(lock_ptr, flags);
+
+#endif
+
+       return flags;
+}
+
+static inline void comedi_spin_unlock_irqrestore(spinlock_t *lock_ptr, unsigned long flags)
+{
 
 #if defined(CONFIG_COMEDI_RTAI)
-#define comedi_spin_lock_irqsave(x, flags)             \
-       (flags = rt_spin_lock_irqsave(x))
-#define comedi_spin_unlock_irqrestore(x, flags)                \
-       rt_spin_unlock_irqrestore(flags, x)
+       rt_spin_unlock_irqrestore(flags, lock_ptr);
 
 #elif defined(CONFIG_COMEDI_RTL)
-#define comedi_spin_lock_irqsave(x, flags)             \
-       rtl_spin_lock_irqsave(x, flags)
-#define comedi_spin_unlock_irqrestore(x, flags)                \
-       rtl_spin_unlock_irqrestore(x, flags)
+       rtl_spin_unlock_irqrestore(lock_ptr, flags);
 
 #elif defined(CONFIG_COMEDI_RTL_V1)
-#define comedi_spin_lock_irqsave(x, flags)             \
-       rtl_spin_lock_irqsave(x, flags)
-#define comedi_spin_unlock_irqrestore(x, flags)                \
-       rtl_spin_unlock_irqrestore(x, flags)
+       rtl_spin_unlock_irqrestore(lock_ptr, flags);
 
 #else
-#define comedi_spin_lock_irqsave(x, flags)     spin_lock_irqsave(x, flags)
-#define comedi_spin_unlock_irqrestore(x, flags)        spin_unlock_irqrestore(x, flags)
+       spin_unlock_irqrestore(lock_ptr, flags);
 
 #endif
 
+}
 
 #endif