diff options
Diffstat (limited to 'include/linux/rwsem.h')
-rw-r--r-- | include/linux/rwsem.h | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 93581534b915..658afb37c3f5 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
@@ -27,64 +27,55 @@ struct rw_semaphore; | |||
27 | /* | 27 | /* |
28 | * lock for reading | 28 | * lock for reading |
29 | */ | 29 | */ |
30 | static inline void down_read(struct rw_semaphore *sem) | 30 | extern void down_read(struct rw_semaphore *sem); |
31 | { | ||
32 | might_sleep(); | ||
33 | __down_read(sem); | ||
34 | } | ||
35 | 31 | ||
36 | /* | 32 | /* |
37 | * trylock for reading -- returns 1 if successful, 0 if contention | 33 | * trylock for reading -- returns 1 if successful, 0 if contention |
38 | */ | 34 | */ |
39 | static inline int down_read_trylock(struct rw_semaphore *sem) | 35 | extern int down_read_trylock(struct rw_semaphore *sem); |
40 | { | ||
41 | int ret; | ||
42 | ret = __down_read_trylock(sem); | ||
43 | return ret; | ||
44 | } | ||
45 | 36 | ||
46 | /* | 37 | /* |
47 | * lock for writing | 38 | * lock for writing |
48 | */ | 39 | */ |
49 | static inline void down_write(struct rw_semaphore *sem) | 40 | extern void down_write(struct rw_semaphore *sem); |
50 | { | ||
51 | might_sleep(); | ||
52 | __down_write(sem); | ||
53 | } | ||
54 | 41 | ||
55 | /* | 42 | /* |
56 | * trylock for writing -- returns 1 if successful, 0 if contention | 43 | * trylock for writing -- returns 1 if successful, 0 if contention |
57 | */ | 44 | */ |
58 | static inline int down_write_trylock(struct rw_semaphore *sem) | 45 | extern int down_write_trylock(struct rw_semaphore *sem); |
59 | { | ||
60 | int ret; | ||
61 | ret = __down_write_trylock(sem); | ||
62 | return ret; | ||
63 | } | ||
64 | 46 | ||
65 | /* | 47 | /* |
66 | * release a read lock | 48 | * release a read lock |
67 | */ | 49 | */ |
68 | static inline void up_read(struct rw_semaphore *sem) | 50 | extern void up_read(struct rw_semaphore *sem); |
69 | { | ||
70 | __up_read(sem); | ||
71 | } | ||
72 | 51 | ||
73 | /* | 52 | /* |
74 | * release a write lock | 53 | * release a write lock |
75 | */ | 54 | */ |
76 | static inline void up_write(struct rw_semaphore *sem) | 55 | extern void up_write(struct rw_semaphore *sem); |
77 | { | ||
78 | __up_write(sem); | ||
79 | } | ||
80 | 56 | ||
81 | /* | 57 | /* |
82 | * downgrade write lock to read lock | 58 | * downgrade write lock to read lock |
83 | */ | 59 | */ |
84 | static inline void downgrade_write(struct rw_semaphore *sem) | 60 | extern void downgrade_write(struct rw_semaphore *sem); |
85 | { | 61 | |
86 | __downgrade_write(sem); | 62 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
87 | } | 63 | /* |
64 | * nested locking: | ||
65 | */ | ||
66 | extern void down_read_nested(struct rw_semaphore *sem, int subclass); | ||
67 | extern void down_write_nested(struct rw_semaphore *sem, int subclass); | ||
68 | /* | ||
69 | * Take/release a lock when not the owner will release it: | ||
70 | */ | ||
71 | extern void down_read_non_owner(struct rw_semaphore *sem); | ||
72 | extern void up_read_non_owner(struct rw_semaphore *sem); | ||
73 | #else | ||
74 | # define down_read_nested(sem, subclass) down_read(sem) | ||
75 | # define down_write_nested(sem, subclass) down_write(sem) | ||
76 | # define down_read_non_owner(sem) down_read(sem) | ||
77 | # define up_read_non_owner(sem) up_read(sem) | ||
78 | #endif | ||
88 | 79 | ||
89 | #endif /* __KERNEL__ */ | 80 | #endif /* __KERNEL__ */ |
90 | #endif /* _LINUX_RWSEM_H */ | 81 | #endif /* _LINUX_RWSEM_H */ |