From 782ae0b7c0a90e56b1142cbd05a91a5084a413e3 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 3 Apr 2001 23:45:56 +0000 Subject: [PATCH] made comedi_spinlock functions do some type checking for standard linux and rtlinux spinlocks --- include/linux/comedi_rt.h | 50 +++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/include/linux/comedi_rt.h b/include/linux/comedi_rt.h index 41d9c922..d4208170 100644 --- a/include/linux/comedi_rt.h +++ b/include/linux/comedi_rt.h @@ -30,6 +30,7 @@ #include #include #include +#include #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 -- 2.26.2