[PATCH] bcm43xx: Fix array overrun in bcm43xx_geo_init
[linux-2.6/kmemtrace.git] / include / linux / rwsem.h
blobbfb98888500290d3c945f93e2f544de1384bcacb
1 /* rwsem.h: R/W semaphores, public interface
3 * Written by David Howells (dhowells@redhat.com).
4 * Derived from asm-i386/semaphore.h
5 */
7 #ifndef _LINUX_RWSEM_H
8 #define _LINUX_RWSEM_H
10 #include <linux/linkage.h>
12 #define RWSEM_DEBUG 0
14 #ifdef __KERNEL__
16 #include <linux/config.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <asm/system.h>
20 #include <asm/atomic.h>
22 struct rw_semaphore;
24 #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
25 #include <linux/rwsem-spinlock.h> /* use a generic implementation */
26 #else
27 #include <asm/rwsem.h> /* use an arch-specific implementation */
28 #endif
30 #ifndef rwsemtrace
31 #if RWSEM_DEBUG
32 extern void FASTCALL(rwsemtrace(struct rw_semaphore *sem, const char *str));
33 #else
34 #define rwsemtrace(SEM,FMT)
35 #endif
36 #endif
39 * lock for reading
41 static inline void down_read(struct rw_semaphore *sem)
43 might_sleep();
44 rwsemtrace(sem,"Entering down_read");
45 __down_read(sem);
46 rwsemtrace(sem,"Leaving down_read");
50 * trylock for reading -- returns 1 if successful, 0 if contention
52 static inline int down_read_trylock(struct rw_semaphore *sem)
54 int ret;
55 rwsemtrace(sem,"Entering down_read_trylock");
56 ret = __down_read_trylock(sem);
57 rwsemtrace(sem,"Leaving down_read_trylock");
58 return ret;
62 * lock for writing
64 static inline void down_write(struct rw_semaphore *sem)
66 might_sleep();
67 rwsemtrace(sem,"Entering down_write");
68 __down_write(sem);
69 rwsemtrace(sem,"Leaving down_write");
73 * trylock for writing -- returns 1 if successful, 0 if contention
75 static inline int down_write_trylock(struct rw_semaphore *sem)
77 int ret;
78 rwsemtrace(sem,"Entering down_write_trylock");
79 ret = __down_write_trylock(sem);
80 rwsemtrace(sem,"Leaving down_write_trylock");
81 return ret;
85 * release a read lock
87 static inline void up_read(struct rw_semaphore *sem)
89 rwsemtrace(sem,"Entering up_read");
90 __up_read(sem);
91 rwsemtrace(sem,"Leaving up_read");
95 * release a write lock
97 static inline void up_write(struct rw_semaphore *sem)
99 rwsemtrace(sem,"Entering up_write");
100 __up_write(sem);
101 rwsemtrace(sem,"Leaving up_write");
105 * downgrade write lock to read lock
107 static inline void downgrade_write(struct rw_semaphore *sem)
109 rwsemtrace(sem,"Entering downgrade_write");
110 __downgrade_write(sem);
111 rwsemtrace(sem,"Leaving downgrade_write");
114 #endif /* __KERNEL__ */
115 #endif /* _LINUX_RWSEM_H */