diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-11-07 17:04:15 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-12-14 17:55:32 -0500 |
commit | ef12f10994281e2e44526fa0abf23fdd7d5bd87f (patch) | |
tree | 6060e8b412fe7aea40462106be10eca8dcb1754d /include | |
parent | b7b40ade58e621851896aa261452df99d4e9d99b (diff) |
locking: Split rwlock from spinlock headers
Move the rwlock defines and inlines into separate header files. This
makes the selection for -rt easier.
No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/rwlock.h | 125 | ||||
-rw-r--r-- | include/linux/rwlock_types.h | 56 | ||||
-rw-r--r-- | include/linux/spinlock.h | 100 | ||||
-rw-r--r-- | include/linux/spinlock_types.h | 43 |
4 files changed, 195 insertions, 129 deletions
diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h new file mode 100644 index 000000000000..73785b0bd6b9 --- /dev/null +++ b/include/linux/rwlock.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef __LINUX_RWLOCK_H | ||
2 | #define __LINUX_RWLOCK_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | /* | ||
9 | * rwlock related methods | ||
10 | * | ||
11 | * split out from spinlock.h | ||
12 | * | ||
13 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
14 | * Released under the General Public License (GPL). | ||
15 | */ | ||
16 | |||
17 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
18 | extern void __rwlock_init(rwlock_t *lock, const char *name, | ||
19 | struct lock_class_key *key); | ||
20 | # define rwlock_init(lock) \ | ||
21 | do { \ | ||
22 | static struct lock_class_key __key; \ | ||
23 | \ | ||
24 | __rwlock_init((lock), #lock, &__key); \ | ||
25 | } while (0) | ||
26 | #else | ||
27 | # define rwlock_init(lock) \ | ||
28 | do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0) | ||
29 | #endif | ||
30 | |||
31 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
32 | extern void _raw_read_lock(rwlock_t *lock); | ||
33 | #define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock) | ||
34 | extern int _raw_read_trylock(rwlock_t *lock); | ||
35 | extern void _raw_read_unlock(rwlock_t *lock); | ||
36 | extern void _raw_write_lock(rwlock_t *lock); | ||
37 | #define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock) | ||
38 | extern int _raw_write_trylock(rwlock_t *lock); | ||
39 | extern void _raw_write_unlock(rwlock_t *lock); | ||
40 | #else | ||
41 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) | ||
42 | # define _raw_read_lock_flags(lock, flags) \ | ||
43 | __raw_read_lock_flags(&(lock)->raw_lock, *(flags)) | ||
44 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) | ||
45 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) | ||
46 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) | ||
47 | # define _raw_write_lock_flags(lock, flags) \ | ||
48 | __raw_write_lock_flags(&(lock)->raw_lock, *(flags)) | ||
49 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) | ||
50 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) | ||
51 | #endif | ||
52 | |||
53 | #define read_can_lock(rwlock) __raw_read_can_lock(&(rwlock)->raw_lock) | ||
54 | #define write_can_lock(rwlock) __raw_write_can_lock(&(rwlock)->raw_lock) | ||
55 | |||
56 | /* | ||
57 | * Define the various rw_lock methods. Note we define these | ||
58 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various | ||
59 | * methods are defined as nops in the case they are not required. | ||
60 | */ | ||
61 | #define read_trylock(lock) __cond_lock(lock, _read_trylock(lock)) | ||
62 | #define write_trylock(lock) __cond_lock(lock, _write_trylock(lock)) | ||
63 | |||
64 | #define write_lock(lock) _write_lock(lock) | ||
65 | #define read_lock(lock) _read_lock(lock) | ||
66 | |||
67 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
68 | |||
69 | #define read_lock_irqsave(lock, flags) \ | ||
70 | do { \ | ||
71 | typecheck(unsigned long, flags); \ | ||
72 | flags = _read_lock_irqsave(lock); \ | ||
73 | } while (0) | ||
74 | #define write_lock_irqsave(lock, flags) \ | ||
75 | do { \ | ||
76 | typecheck(unsigned long, flags); \ | ||
77 | flags = _write_lock_irqsave(lock); \ | ||
78 | } while (0) | ||
79 | |||
80 | #else | ||
81 | |||
82 | #define read_lock_irqsave(lock, flags) \ | ||
83 | do { \ | ||
84 | typecheck(unsigned long, flags); \ | ||
85 | _read_lock_irqsave(lock, flags); \ | ||
86 | } while (0) | ||
87 | #define write_lock_irqsave(lock, flags) \ | ||
88 | do { \ | ||
89 | typecheck(unsigned long, flags); \ | ||
90 | _write_lock_irqsave(lock, flags); \ | ||
91 | } while (0) | ||
92 | |||
93 | #endif | ||
94 | |||
95 | #define read_lock_irq(lock) _read_lock_irq(lock) | ||
96 | #define read_lock_bh(lock) _read_lock_bh(lock) | ||
97 | #define write_lock_irq(lock) _write_lock_irq(lock) | ||
98 | #define write_lock_bh(lock) _write_lock_bh(lock) | ||
99 | #define read_unlock(lock) _read_unlock(lock) | ||
100 | #define write_unlock(lock) _write_unlock(lock) | ||
101 | #define read_unlock_irq(lock) _read_unlock_irq(lock) | ||
102 | #define write_unlock_irq(lock) _write_unlock_irq(lock) | ||
103 | |||
104 | #define read_unlock_irqrestore(lock, flags) \ | ||
105 | do { \ | ||
106 | typecheck(unsigned long, flags); \ | ||
107 | _read_unlock_irqrestore(lock, flags); \ | ||
108 | } while (0) | ||
109 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | ||
110 | |||
111 | #define write_unlock_irqrestore(lock, flags) \ | ||
112 | do { \ | ||
113 | typecheck(unsigned long, flags); \ | ||
114 | _write_unlock_irqrestore(lock, flags); \ | ||
115 | } while (0) | ||
116 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | ||
117 | |||
118 | #define write_trylock_irqsave(lock, flags) \ | ||
119 | ({ \ | ||
120 | local_irq_save(flags); \ | ||
121 | write_trylock(lock) ? \ | ||
122 | 1 : ({ local_irq_restore(flags); 0; }); \ | ||
123 | }) | ||
124 | |||
125 | #endif /* __LINUX_RWLOCK_H */ | ||
diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h new file mode 100644 index 000000000000..f8c935206a41 --- /dev/null +++ b/include/linux/rwlock_types.h | |||
@@ -0,0 +1,56 @@ | |||
1 | #ifndef __LINUX_RWLOCK_TYPES_H | ||
2 | #define __LINUX_RWLOCK_TYPES_H | ||
3 | |||
4 | /* | ||
5 | * include/linux/rwlock_types.h - generic rwlock type definitions | ||
6 | * and initializers | ||
7 | * | ||
8 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
9 | * Released under the General Public License (GPL). | ||
10 | */ | ||
11 | typedef struct { | ||
12 | raw_rwlock_t raw_lock; | ||
13 | #ifdef CONFIG_GENERIC_LOCKBREAK | ||
14 | unsigned int break_lock; | ||
15 | #endif | ||
16 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
17 | unsigned int magic, owner_cpu; | ||
18 | void *owner; | ||
19 | #endif | ||
20 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
21 | struct lockdep_map dep_map; | ||
22 | #endif | ||
23 | } rwlock_t; | ||
24 | |||
25 | #define RWLOCK_MAGIC 0xdeaf1eed | ||
26 | |||
27 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
28 | # define RW_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } | ||
29 | #else | ||
30 | # define RW_DEP_MAP_INIT(lockname) | ||
31 | #endif | ||
32 | |||
33 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
34 | #define __RW_LOCK_UNLOCKED(lockname) \ | ||
35 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
36 | .magic = RWLOCK_MAGIC, \ | ||
37 | .owner = SPINLOCK_OWNER_INIT, \ | ||
38 | .owner_cpu = -1, \ | ||
39 | RW_DEP_MAP_INIT(lockname) } | ||
40 | #else | ||
41 | #define __RW_LOCK_UNLOCKED(lockname) \ | ||
42 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
43 | RW_DEP_MAP_INIT(lockname) } | ||
44 | #endif | ||
45 | |||
46 | /* | ||
47 | * RW_LOCK_UNLOCKED defeat lockdep state tracking and is hence | ||
48 | * deprecated. | ||
49 | * | ||
50 | * Please use DEFINE_RWLOCK() or __RW_LOCK_UNLOCKED() as appropriate. | ||
51 | */ | ||
52 | #define RW_LOCK_UNLOCKED __RW_LOCK_UNLOCKED(old_style_rw_init) | ||
53 | |||
54 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) | ||
55 | |||
56 | #endif /* __LINUX_RWLOCK_TYPES_H */ | ||
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 71dccfeb0d88..a9aaa709fb93 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
@@ -103,20 +103,6 @@ do { \ | |||
103 | do { *(lock) = __SPIN_LOCK_UNLOCKED(lock); } while (0) | 103 | do { *(lock) = __SPIN_LOCK_UNLOCKED(lock); } while (0) |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
107 | extern void __rwlock_init(rwlock_t *lock, const char *name, | ||
108 | struct lock_class_key *key); | ||
109 | # define rwlock_init(lock) \ | ||
110 | do { \ | ||
111 | static struct lock_class_key __key; \ | ||
112 | \ | ||
113 | __rwlock_init((lock), #lock, &__key); \ | ||
114 | } while (0) | ||
115 | #else | ||
116 | # define rwlock_init(lock) \ | ||
117 | do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0) | ||
118 | #endif | ||
119 | |||
120 | #define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) | 106 | #define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) |
121 | 107 | ||
122 | #ifdef CONFIG_GENERIC_LOCKBREAK | 108 | #ifdef CONFIG_GENERIC_LOCKBREAK |
@@ -146,43 +132,21 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
146 | #define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock) | 132 | #define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock) |
147 | extern int _raw_spin_trylock(spinlock_t *lock); | 133 | extern int _raw_spin_trylock(spinlock_t *lock); |
148 | extern void _raw_spin_unlock(spinlock_t *lock); | 134 | extern void _raw_spin_unlock(spinlock_t *lock); |
149 | extern void _raw_read_lock(rwlock_t *lock); | ||
150 | #define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock) | ||
151 | extern int _raw_read_trylock(rwlock_t *lock); | ||
152 | extern void _raw_read_unlock(rwlock_t *lock); | ||
153 | extern void _raw_write_lock(rwlock_t *lock); | ||
154 | #define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock) | ||
155 | extern int _raw_write_trylock(rwlock_t *lock); | ||
156 | extern void _raw_write_unlock(rwlock_t *lock); | ||
157 | #else | 135 | #else |
158 | # define _raw_spin_lock(lock) __raw_spin_lock(&(lock)->raw_lock) | 136 | # define _raw_spin_lock(lock) __raw_spin_lock(&(lock)->raw_lock) |
159 | # define _raw_spin_lock_flags(lock, flags) \ | 137 | # define _raw_spin_lock_flags(lock, flags) \ |
160 | __raw_spin_lock_flags(&(lock)->raw_lock, *(flags)) | 138 | __raw_spin_lock_flags(&(lock)->raw_lock, *(flags)) |
161 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) | 139 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) |
162 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) | 140 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) |
163 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) | ||
164 | # define _raw_read_lock_flags(lock, flags) \ | ||
165 | __raw_read_lock_flags(&(lock)->raw_lock, *(flags)) | ||
166 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) | ||
167 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) | ||
168 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) | ||
169 | # define _raw_write_lock_flags(lock, flags) \ | ||
170 | __raw_write_lock_flags(&(lock)->raw_lock, *(flags)) | ||
171 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) | ||
172 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) | ||
173 | #endif | 141 | #endif |
174 | 142 | ||
175 | #define read_can_lock(rwlock) __raw_read_can_lock(&(rwlock)->raw_lock) | ||
176 | #define write_can_lock(rwlock) __raw_write_can_lock(&(rwlock)->raw_lock) | ||
177 | |||
178 | /* | 143 | /* |
179 | * Define the various spin_lock and rw_lock methods. Note we define these | 144 | * Define the various spin_lock methods. Note we define these |
180 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various | 145 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The |
181 | * methods are defined as nops in the case they are not required. | 146 | * various methods are defined as nops in the case they are not |
147 | * required. | ||
182 | */ | 148 | */ |
183 | #define spin_trylock(lock) __cond_lock(lock, _spin_trylock(lock)) | 149 | #define spin_trylock(lock) __cond_lock(lock, _spin_trylock(lock)) |
184 | #define read_trylock(lock) __cond_lock(lock, _read_trylock(lock)) | ||
185 | #define write_trylock(lock) __cond_lock(lock, _write_trylock(lock)) | ||
186 | 150 | ||
187 | #define spin_lock(lock) _spin_lock(lock) | 151 | #define spin_lock(lock) _spin_lock(lock) |
188 | 152 | ||
@@ -198,9 +162,6 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
198 | # define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock) | 162 | # define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock) |
199 | #endif | 163 | #endif |
200 | 164 | ||
201 | #define write_lock(lock) _write_lock(lock) | ||
202 | #define read_lock(lock) _read_lock(lock) | ||
203 | |||
204 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 165 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
205 | 166 | ||
206 | #define spin_lock_irqsave(lock, flags) \ | 167 | #define spin_lock_irqsave(lock, flags) \ |
@@ -208,16 +169,6 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
208 | typecheck(unsigned long, flags); \ | 169 | typecheck(unsigned long, flags); \ |
209 | flags = _spin_lock_irqsave(lock); \ | 170 | flags = _spin_lock_irqsave(lock); \ |
210 | } while (0) | 171 | } while (0) |
211 | #define read_lock_irqsave(lock, flags) \ | ||
212 | do { \ | ||
213 | typecheck(unsigned long, flags); \ | ||
214 | flags = _read_lock_irqsave(lock); \ | ||
215 | } while (0) | ||
216 | #define write_lock_irqsave(lock, flags) \ | ||
217 | do { \ | ||
218 | typecheck(unsigned long, flags); \ | ||
219 | flags = _write_lock_irqsave(lock); \ | ||
220 | } while (0) | ||
221 | 172 | ||
222 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 173 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
223 | #define spin_lock_irqsave_nested(lock, flags, subclass) \ | 174 | #define spin_lock_irqsave_nested(lock, flags, subclass) \ |
@@ -240,16 +191,7 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
240 | typecheck(unsigned long, flags); \ | 191 | typecheck(unsigned long, flags); \ |
241 | _spin_lock_irqsave(lock, flags); \ | 192 | _spin_lock_irqsave(lock, flags); \ |
242 | } while (0) | 193 | } while (0) |
243 | #define read_lock_irqsave(lock, flags) \ | 194 | |
244 | do { \ | ||
245 | typecheck(unsigned long, flags); \ | ||
246 | _read_lock_irqsave(lock, flags); \ | ||
247 | } while (0) | ||
248 | #define write_lock_irqsave(lock, flags) \ | ||
249 | do { \ | ||
250 | typecheck(unsigned long, flags); \ | ||
251 | _write_lock_irqsave(lock, flags); \ | ||
252 | } while (0) | ||
253 | #define spin_lock_irqsave_nested(lock, flags, subclass) \ | 195 | #define spin_lock_irqsave_nested(lock, flags, subclass) \ |
254 | spin_lock_irqsave(lock, flags) | 196 | spin_lock_irqsave(lock, flags) |
255 | 197 | ||
@@ -257,16 +199,8 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
257 | 199 | ||
258 | #define spin_lock_irq(lock) _spin_lock_irq(lock) | 200 | #define spin_lock_irq(lock) _spin_lock_irq(lock) |
259 | #define spin_lock_bh(lock) _spin_lock_bh(lock) | 201 | #define spin_lock_bh(lock) _spin_lock_bh(lock) |
260 | #define read_lock_irq(lock) _read_lock_irq(lock) | ||
261 | #define read_lock_bh(lock) _read_lock_bh(lock) | ||
262 | #define write_lock_irq(lock) _write_lock_irq(lock) | ||
263 | #define write_lock_bh(lock) _write_lock_bh(lock) | ||
264 | #define spin_unlock(lock) _spin_unlock(lock) | 202 | #define spin_unlock(lock) _spin_unlock(lock) |
265 | #define read_unlock(lock) _read_unlock(lock) | ||
266 | #define write_unlock(lock) _write_unlock(lock) | ||
267 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) | 203 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) |
268 | #define read_unlock_irq(lock) _read_unlock_irq(lock) | ||
269 | #define write_unlock_irq(lock) _write_unlock_irq(lock) | ||
270 | 204 | ||
271 | #define spin_unlock_irqrestore(lock, flags) \ | 205 | #define spin_unlock_irqrestore(lock, flags) \ |
272 | do { \ | 206 | do { \ |
@@ -275,20 +209,6 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
275 | } while (0) | 209 | } while (0) |
276 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) | 210 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) |
277 | 211 | ||
278 | #define read_unlock_irqrestore(lock, flags) \ | ||
279 | do { \ | ||
280 | typecheck(unsigned long, flags); \ | ||
281 | _read_unlock_irqrestore(lock, flags); \ | ||
282 | } while (0) | ||
283 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | ||
284 | |||
285 | #define write_unlock_irqrestore(lock, flags) \ | ||
286 | do { \ | ||
287 | typecheck(unsigned long, flags); \ | ||
288 | _write_unlock_irqrestore(lock, flags); \ | ||
289 | } while (0) | ||
290 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | ||
291 | |||
292 | #define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock)) | 212 | #define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock)) |
293 | 213 | ||
294 | #define spin_trylock_irq(lock) \ | 214 | #define spin_trylock_irq(lock) \ |
@@ -305,13 +225,6 @@ static inline void smp_mb__after_lock(void) { smp_mb(); } | |||
305 | 1 : ({ local_irq_restore(flags); 0; }); \ | 225 | 1 : ({ local_irq_restore(flags); 0; }); \ |
306 | }) | 226 | }) |
307 | 227 | ||
308 | #define write_trylock_irqsave(lock, flags) \ | ||
309 | ({ \ | ||
310 | local_irq_save(flags); \ | ||
311 | write_trylock(lock) ? \ | ||
312 | 1 : ({ local_irq_restore(flags); 0; }); \ | ||
313 | }) | ||
314 | |||
315 | /* | 228 | /* |
316 | * Pull the atomic_t declaration: | 229 | * Pull the atomic_t declaration: |
317 | * (asm-mips/atomic.h needs above definitions) | 230 | * (asm-mips/atomic.h needs above definitions) |
@@ -335,6 +248,9 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); | |||
335 | */ | 248 | */ |
336 | #define spin_can_lock(lock) (!spin_is_locked(lock)) | 249 | #define spin_can_lock(lock) (!spin_is_locked(lock)) |
337 | 250 | ||
251 | /* Include rwlock functions */ | ||
252 | #include <linux/rwlock.h> | ||
253 | |||
338 | /* | 254 | /* |
339 | * Pull the _spin_*()/_read_*()/_write_*() functions/declarations: | 255 | * Pull the _spin_*()/_read_*()/_write_*() functions/declarations: |
340 | */ | 256 | */ |
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 68d88f71f1a2..f979d5d8a160 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h | |||
@@ -33,22 +33,6 @@ typedef struct { | |||
33 | 33 | ||
34 | #define SPINLOCK_MAGIC 0xdead4ead | 34 | #define SPINLOCK_MAGIC 0xdead4ead |
35 | 35 | ||
36 | typedef struct { | ||
37 | raw_rwlock_t raw_lock; | ||
38 | #ifdef CONFIG_GENERIC_LOCKBREAK | ||
39 | unsigned int break_lock; | ||
40 | #endif | ||
41 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
42 | unsigned int magic, owner_cpu; | ||
43 | void *owner; | ||
44 | #endif | ||
45 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
46 | struct lockdep_map dep_map; | ||
47 | #endif | ||
48 | } rwlock_t; | ||
49 | |||
50 | #define RWLOCK_MAGIC 0xdeaf1eed | ||
51 | |||
52 | #define SPINLOCK_OWNER_INIT ((void *)-1L) | 36 | #define SPINLOCK_OWNER_INIT ((void *)-1L) |
53 | 37 | ||
54 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
@@ -57,12 +41,6 @@ typedef struct { | |||
57 | # define SPIN_DEP_MAP_INIT(lockname) | 41 | # define SPIN_DEP_MAP_INIT(lockname) |
58 | #endif | 42 | #endif |
59 | 43 | ||
60 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
61 | # define RW_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } | ||
62 | #else | ||
63 | # define RW_DEP_MAP_INIT(lockname) | ||
64 | #endif | ||
65 | |||
66 | #ifdef CONFIG_DEBUG_SPINLOCK | 44 | #ifdef CONFIG_DEBUG_SPINLOCK |
67 | # define __SPIN_LOCK_UNLOCKED(lockname) \ | 45 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
68 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ | 46 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ |
@@ -70,31 +48,22 @@ typedef struct { | |||
70 | .owner = SPINLOCK_OWNER_INIT, \ | 48 | .owner = SPINLOCK_OWNER_INIT, \ |
71 | .owner_cpu = -1, \ | 49 | .owner_cpu = -1, \ |
72 | SPIN_DEP_MAP_INIT(lockname) } | 50 | SPIN_DEP_MAP_INIT(lockname) } |
73 | #define __RW_LOCK_UNLOCKED(lockname) \ | ||
74 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
75 | .magic = RWLOCK_MAGIC, \ | ||
76 | .owner = SPINLOCK_OWNER_INIT, \ | ||
77 | .owner_cpu = -1, \ | ||
78 | RW_DEP_MAP_INIT(lockname) } | ||
79 | #else | 51 | #else |
80 | # define __SPIN_LOCK_UNLOCKED(lockname) \ | 52 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
81 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ | 53 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ |
82 | SPIN_DEP_MAP_INIT(lockname) } | 54 | SPIN_DEP_MAP_INIT(lockname) } |
83 | #define __RW_LOCK_UNLOCKED(lockname) \ | ||
84 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
85 | RW_DEP_MAP_INIT(lockname) } | ||
86 | #endif | 55 | #endif |
87 | 56 | ||
88 | /* | 57 | /* |
89 | * SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and | 58 | * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence |
90 | * are hence deprecated. | 59 | * deprecated. |
91 | * Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or | 60 | * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as |
92 | * __SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate. | 61 | * appropriate. |
93 | */ | 62 | */ |
94 | #define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init) | 63 | #define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init) |
95 | #define RW_LOCK_UNLOCKED __RW_LOCK_UNLOCKED(old_style_rw_init) | ||
96 | 64 | ||
97 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) | 65 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) |
98 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) | 66 | |
67 | #include <linux/rwlock_types.h> | ||
99 | 68 | ||
100 | #endif /* __LINUX_SPINLOCK_TYPES_H */ | 69 | #endif /* __LINUX_SPINLOCK_TYPES_H */ |