Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / smp_lock.h
blob291f721144c2e23c51e4fbb92288f89e6b68dc11
1 #ifndef __LINUX_SMPLOCK_H
2 #define __LINUX_SMPLOCK_H
4 #ifdef CONFIG_LOCK_KERNEL
5 #include <linux/sched.h>
7 #define kernel_locked() (current->lock_depth >= 0)
9 extern int __lockfunc __reacquire_kernel_lock(void);
10 extern void __lockfunc __release_kernel_lock(void);
13 * Release/re-acquire global kernel lock for the scheduler
15 #define release_kernel_lock(tsk) do { \
16 if (unlikely((tsk)->lock_depth >= 0)) \
17 __release_kernel_lock(); \
18 } while (0)
20 static inline int reacquire_kernel_lock(struct task_struct *task)
22 if (unlikely(task->lock_depth >= 0))
23 return __reacquire_kernel_lock();
24 return 0;
27 extern void __lockfunc
28 _lock_kernel(const char *func, const char *file, int line)
29 __acquires(kernel_lock);
31 extern void __lockfunc
32 _unlock_kernel(const char *func, const char *file, int line)
33 __releases(kernel_lock);
35 #define lock_kernel() do { \
36 _lock_kernel(__func__, __FILE__, __LINE__); \
37 } while (0)
39 #define unlock_kernel() do { \
40 _unlock_kernel(__func__, __FILE__, __LINE__); \
41 } while (0)
44 * Various legacy drivers don't really need the BKL in a specific
45 * function, but they *do* need to know that the BKL became available.
46 * This function just avoids wrapping a bunch of lock/unlock pairs
47 * around code which doesn't really need it.
49 static inline void cycle_kernel_lock(void)
51 lock_kernel();
52 unlock_kernel();
55 #else
57 #ifdef CONFIG_BKL /* provoke build bug if not set */
58 #define lock_kernel()
59 #define unlock_kernel()
60 #define cycle_kernel_lock() do { } while(0)
61 #define kernel_locked() 1
62 #endif /* CONFIG_BKL */
64 #define release_kernel_lock(task) do { } while(0)
65 #define reacquire_kernel_lock(task) 0
67 #endif /* CONFIG_LOCK_KERNEL */
68 #endif /* __LINUX_SMPLOCK_H */