aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/include/asm/rwsem.h14
-rw-r--r--arch/ia64/include/asm/rwsem.h15
-rw-r--r--arch/powerpc/include/asm/rwsem.h27
-rw-r--r--arch/s390/include/asm/rwsem.h35
-rw-r--r--arch/sh/include/asm/rwsem.h31
-rw-r--r--arch/sparc/include/asm/rwsem.h23
-rw-r--r--arch/x86/include/asm/rwsem.h25
-rw-r--r--arch/xtensa/include/asm/rwsem.h14
-rw-r--r--include/linux/rwsem-spinlock.h23
-rw-r--r--include/linux/rwsem.h25
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
36static 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
43static inline void __down_read(struct rw_semaphore *sem) 29static 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
44extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); 37extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
45extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); 38extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
46extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 39extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
47extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 40extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
48 41
49static inline void
50init_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
48extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); 31extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
49extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); 32extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
50extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 33extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
51extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 34extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
52 35
53extern 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
83static 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
90extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
91 struct lock_class_key *key);
92
93#define init_rwsem(sem) \
94do { \
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 */
104static inline void __down_read(struct rw_semaphore *sem) 69static 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
36extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); 22extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
37extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); 23extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
38extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 24extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
39extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 25extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
40 26
41extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
42 struct lock_class_key *key);
43
44#define init_rwsem(sem) \
45do { \
46 static struct lock_class_key __key; \
47 \
48 __init_rwsem((sem), #sem, &__key); \
49} while (0)
50
51static 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
36extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); 23extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
37extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); 24extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
38extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 25extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
39extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 26extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
40 27
41extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
42 struct lock_class_key *key);
43
44#define init_rwsem(sem) \
45do { \
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
84extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
85 struct lock_class_key *key);
86
87#define init_rwsem(sem) \
88do { \
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
34extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); 27extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
35extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); 28extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
36extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 29extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
37extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 30extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
38 31
39static 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
45extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
46 struct lock_class_key *key);
47
48#define init_rwsem(sem) \
49do { \
50 static struct lock_class_key __key; \
51 \
52 __init_rwsem((sem), #sem, &__key); \
53} while (0)
54 33
55extern void __down_read(struct rw_semaphore *sem); 34extern void __down_read(struct rw_semaphore *sem);
56extern int __down_read_trylock(struct rw_semaphore *sem); 35extern 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
54extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
55 struct lock_class_key *key);
56
57#define init_rwsem(sem) \
58do { \
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 */