diff options
-rw-r--r-- | arch/alpha/include/asm/rwsem.h | 14 | ||||
-rw-r--r-- | arch/ia64/include/asm/rwsem.h | 15 | ||||
-rw-r--r-- | arch/powerpc/include/asm/rwsem.h | 27 | ||||
-rw-r--r-- | arch/s390/include/asm/rwsem.h | 35 | ||||
-rw-r--r-- | arch/sh/include/asm/rwsem.h | 31 | ||||
-rw-r--r-- | arch/sparc/include/asm/rwsem.h | 23 | ||||
-rw-r--r-- | arch/x86/include/asm/rwsem.h | 25 | ||||
-rw-r--r-- | arch/xtensa/include/asm/rwsem.h | 14 | ||||
-rw-r--r-- | include/linux/rwsem-spinlock.h | 23 | ||||
-rw-r--r-- | include/linux/rwsem.h | 25 |
10 files changed, 26 insertions, 206 deletions
diff --git a/arch/alpha/include/asm/rwsem.h b/arch/alpha/include/asm/rwsem.h index 3e5619ead29d..c9f5b90e926e 100644 --- a/arch/alpha/include/asm/rwsem.h +++ b/arch/alpha/include/asm/rwsem.h | |||
@@ -26,20 +26,6 @@ extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | |||
26 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 26 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
27 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 27 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
28 | 28 | ||
29 | #define __RWSEM_INITIALIZER(name) \ | ||
30 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
31 | LIST_HEAD_INIT((name).wait_list) } | ||
32 | |||
33 | #define DECLARE_RWSEM(name) \ | ||
34 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
35 | |||
36 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
37 | { | ||
38 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
39 | spin_lock_init(&sem->wait_lock); | ||
40 | INIT_LIST_HEAD(&sem->wait_list); | ||
41 | } | ||
42 | |||
43 | static inline void __down_read(struct rw_semaphore *sem) | 29 | static inline void __down_read(struct rw_semaphore *sem) |
44 | { | 30 | { |
45 | long oldcount; | 31 | long oldcount; |
diff --git a/arch/ia64/include/asm/rwsem.h b/arch/ia64/include/asm/rwsem.h index 1fe465804dc7..379854630e9d 100644 --- a/arch/ia64/include/asm/rwsem.h +++ b/arch/ia64/include/asm/rwsem.h | |||
@@ -34,26 +34,11 @@ | |||
34 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 34 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
35 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 35 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
36 | 36 | ||
37 | #define __RWSEM_INITIALIZER(name) \ | ||
38 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
39 | LIST_HEAD_INIT((name).wait_list) } | ||
40 | |||
41 | #define DECLARE_RWSEM(name) \ | ||
42 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
43 | |||
44 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | 37 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); |
45 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | 38 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); |
46 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 39 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
47 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 40 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
48 | 41 | ||
49 | static inline void | ||
50 | init_rwsem (struct rw_semaphore *sem) | ||
51 | { | ||
52 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
53 | spin_lock_init(&sem->wait_lock); | ||
54 | INIT_LIST_HEAD(&sem->wait_list); | ||
55 | } | ||
56 | |||
57 | /* | 42 | /* |
58 | * lock for reading | 43 | * lock for reading |
59 | */ | 44 | */ |
diff --git a/arch/powerpc/include/asm/rwsem.h b/arch/powerpc/include/asm/rwsem.h index bc1acc229223..f86fdf743afb 100644 --- a/arch/powerpc/include/asm/rwsem.h +++ b/arch/powerpc/include/asm/rwsem.h | |||
@@ -28,38 +28,11 @@ | |||
28 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 28 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
29 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 29 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
30 | 30 | ||
31 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
32 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
33 | #else | ||
34 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
35 | #endif | ||
36 | |||
37 | #define __RWSEM_INITIALIZER(name) \ | ||
38 | { \ | ||
39 | RWSEM_UNLOCKED_VALUE, \ | ||
40 | __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
41 | LIST_HEAD_INIT((name).wait_list) \ | ||
42 | __RWSEM_DEP_MAP_INIT(name) \ | ||
43 | } | ||
44 | |||
45 | #define DECLARE_RWSEM(name) \ | ||
46 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
47 | |||
48 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | 31 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); |
49 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | 32 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); |
50 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 33 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
51 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 34 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
52 | 35 | ||
53 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
54 | struct lock_class_key *key); | ||
55 | |||
56 | #define init_rwsem(sem) \ | ||
57 | do { \ | ||
58 | static struct lock_class_key __key; \ | ||
59 | \ | ||
60 | __init_rwsem((sem), #sem, &__key); \ | ||
61 | } while (0) | ||
62 | |||
63 | /* | 36 | /* |
64 | * lock for reading | 37 | * lock for reading |
65 | */ | 38 | */ |
diff --git a/arch/s390/include/asm/rwsem.h b/arch/s390/include/asm/rwsem.h index 6e075f1d97b4..f0f527756ee1 100644 --- a/arch/s390/include/asm/rwsem.h +++ b/arch/s390/include/asm/rwsem.h | |||
@@ -64,41 +64,6 @@ extern struct rw_semaphore *rwsem_downgrade_write(struct rw_semaphore *); | |||
64 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 64 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
65 | 65 | ||
66 | /* | 66 | /* |
67 | * initialisation | ||
68 | */ | ||
69 | |||
70 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
71 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
72 | #else | ||
73 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
74 | #endif | ||
75 | |||
76 | #define __RWSEM_INITIALIZER(name) \ | ||
77 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait.lock), \ | ||
78 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
79 | |||
80 | #define DECLARE_RWSEM(name) \ | ||
81 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
82 | |||
83 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
84 | { | ||
85 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
86 | spin_lock_init(&sem->wait_lock); | ||
87 | INIT_LIST_HEAD(&sem->wait_list); | ||
88 | } | ||
89 | |||
90 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
91 | struct lock_class_key *key); | ||
92 | |||
93 | #define init_rwsem(sem) \ | ||
94 | do { \ | ||
95 | static struct lock_class_key __key; \ | ||
96 | \ | ||
97 | __init_rwsem((sem), #sem, &__key); \ | ||
98 | } while (0) | ||
99 | |||
100 | |||
101 | /* | ||
102 | * lock for reading | 67 | * lock for reading |
103 | */ | 68 | */ |
104 | static inline void __down_read(struct rw_semaphore *sem) | 69 | static inline void __down_read(struct rw_semaphore *sem) |
diff --git a/arch/sh/include/asm/rwsem.h b/arch/sh/include/asm/rwsem.h index dffc62589f79..798699d0687b 100644 --- a/arch/sh/include/asm/rwsem.h +++ b/arch/sh/include/asm/rwsem.h | |||
@@ -19,42 +19,11 @@ | |||
19 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 19 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
20 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 20 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
21 | 21 | ||
22 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
23 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
24 | #else | ||
25 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
26 | #endif | ||
27 | |||
28 | #define __RWSEM_INITIALIZER(name) \ | ||
29 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
30 | LIST_HEAD_INIT((name).wait_list) \ | ||
31 | __RWSEM_DEP_MAP_INIT(name) } | ||
32 | |||
33 | #define DECLARE_RWSEM(name) \ | ||
34 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
35 | |||
36 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | 22 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); |
37 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | 23 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); |
38 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 24 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
39 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 25 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
40 | 26 | ||
41 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
42 | struct lock_class_key *key); | ||
43 | |||
44 | #define init_rwsem(sem) \ | ||
45 | do { \ | ||
46 | static struct lock_class_key __key; \ | ||
47 | \ | ||
48 | __init_rwsem((sem), #sem, &__key); \ | ||
49 | } while (0) | ||
50 | |||
51 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
52 | { | ||
53 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
54 | spin_lock_init(&sem->wait_lock); | ||
55 | INIT_LIST_HEAD(&sem->wait_list); | ||
56 | } | ||
57 | |||
58 | /* | 27 | /* |
59 | * lock for reading | 28 | * lock for reading |
60 | */ | 29 | */ |
diff --git a/arch/sparc/include/asm/rwsem.h b/arch/sparc/include/asm/rwsem.h index 4c16d1de2ab5..79f7c1ca6f91 100644 --- a/arch/sparc/include/asm/rwsem.h +++ b/arch/sparc/include/asm/rwsem.h | |||
@@ -20,34 +20,11 @@ | |||
20 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 20 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
21 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 21 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
22 | 22 | ||
23 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
24 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
25 | #else | ||
26 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
27 | #endif | ||
28 | |||
29 | #define __RWSEM_INITIALIZER(name) \ | ||
30 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
31 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
32 | |||
33 | #define DECLARE_RWSEM(name) \ | ||
34 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
35 | |||
36 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | 23 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); |
37 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | 24 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); |
38 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 25 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
39 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 26 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
40 | 27 | ||
41 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
42 | struct lock_class_key *key); | ||
43 | |||
44 | #define init_rwsem(sem) \ | ||
45 | do { \ | ||
46 | static struct lock_class_key __key; \ | ||
47 | \ | ||
48 | __init_rwsem((sem), #sem, &__key); \ | ||
49 | } while (0) | ||
50 | |||
51 | /* | 28 | /* |
52 | * lock for reading | 29 | * lock for reading |
53 | */ | 30 | */ |
diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h index 995cfe4c985d..c0c91b4ecc81 100644 --- a/arch/x86/include/asm/rwsem.h +++ b/arch/x86/include/asm/rwsem.h | |||
@@ -66,31 +66,6 @@ extern asmregparm struct rw_semaphore * | |||
66 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 66 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
67 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 67 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
68 | 68 | ||
69 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
70 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
71 | #else | ||
72 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
73 | #endif | ||
74 | |||
75 | #define __RWSEM_INITIALIZER(name) \ | ||
76 | { \ | ||
77 | RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
78 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) \ | ||
79 | } | ||
80 | |||
81 | #define DECLARE_RWSEM(name) \ | ||
82 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
83 | |||
84 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
85 | struct lock_class_key *key); | ||
86 | |||
87 | #define init_rwsem(sem) \ | ||
88 | do { \ | ||
89 | static struct lock_class_key __key; \ | ||
90 | \ | ||
91 | __init_rwsem((sem), #sem, &__key); \ | ||
92 | } while (0) | ||
93 | |||
94 | /* | 69 | /* |
95 | * lock for reading | 70 | * lock for reading |
96 | */ | 71 | */ |
diff --git a/arch/xtensa/include/asm/rwsem.h b/arch/xtensa/include/asm/rwsem.h index 585cab9b0bdf..2fa420212353 100644 --- a/arch/xtensa/include/asm/rwsem.h +++ b/arch/xtensa/include/asm/rwsem.h | |||
@@ -24,25 +24,11 @@ | |||
24 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 24 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
25 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 25 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
26 | 26 | ||
27 | #define __RWSEM_INITIALIZER(name) \ | ||
28 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
29 | LIST_HEAD_INIT((name).wait_list) } | ||
30 | |||
31 | #define DECLARE_RWSEM(name) \ | ||
32 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
33 | |||
34 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | 27 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); |
35 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | 28 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); |
36 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 29 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
37 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 30 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
38 | 31 | ||
39 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
40 | { | ||
41 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
42 | spin_lock_init(&sem->wait_lock); | ||
43 | INIT_LIST_HEAD(&sem->wait_list); | ||
44 | } | ||
45 | |||
46 | /* | 32 | /* |
47 | * lock for reading | 33 | * lock for reading |
48 | */ | 34 | */ |
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h index 8c0dc7fc07a4..34701241b673 100644 --- a/include/linux/rwsem-spinlock.h +++ b/include/linux/rwsem-spinlock.h | |||
@@ -29,28 +29,7 @@ struct rw_semaphore { | |||
29 | #endif | 29 | #endif |
30 | }; | 30 | }; |
31 | 31 | ||
32 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 32 | #define RWSEM_UNLOCKED_VALUE 0x00000000 |
33 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
34 | #else | ||
35 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
36 | #endif | ||
37 | |||
38 | #define __RWSEM_INITIALIZER(name) \ | ||
39 | { 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \ | ||
40 | __RWSEM_DEP_MAP_INIT(name) } | ||
41 | |||
42 | #define DECLARE_RWSEM(name) \ | ||
43 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
44 | |||
45 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
46 | struct lock_class_key *key); | ||
47 | |||
48 | #define init_rwsem(sem) \ | ||
49 | do { \ | ||
50 | static struct lock_class_key __key; \ | ||
51 | \ | ||
52 | __init_rwsem((sem), #sem, &__key); \ | ||
53 | } while (0) | ||
54 | 33 | ||
55 | extern void __down_read(struct rw_semaphore *sem); | 34 | extern void __down_read(struct rw_semaphore *sem); |
56 | extern int __down_read_trylock(struct rw_semaphore *sem); | 35 | extern int __down_read_trylock(struct rw_semaphore *sem); |
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index e8be18edb664..8970c3e802e2 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
@@ -36,6 +36,31 @@ struct rw_semaphore { | |||
36 | #include <asm/rwsem.h> | 36 | #include <asm/rwsem.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | /* Common initializer macros and functions */ | ||
40 | |||
41 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
42 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
43 | #else | ||
44 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
45 | #endif | ||
46 | |||
47 | #define __RWSEM_INITIALIZER(name) \ | ||
48 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED(name.wait_lock), \ | ||
49 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
50 | |||
51 | #define DECLARE_RWSEM(name) \ | ||
52 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
53 | |||
54 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
55 | struct lock_class_key *key); | ||
56 | |||
57 | #define init_rwsem(sem) \ | ||
58 | do { \ | ||
59 | static struct lock_class_key __key; \ | ||
60 | \ | ||
61 | __init_rwsem((sem), #sem, &__key); \ | ||
62 | } while (0) | ||
63 | |||
39 | /* | 64 | /* |
40 | * lock for reading | 65 | * lock for reading |
41 | */ | 66 | */ |