diff options
Diffstat (limited to 'include/asm-powerpc/rwsem.h')
-rw-r--r-- | include/asm-powerpc/rwsem.h | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h index cefc14728cc5..a6cc93b78b98 100644 --- a/include/asm-powerpc/rwsem.h +++ b/include/asm-powerpc/rwsem.h | |||
@@ -32,11 +32,20 @@ struct rw_semaphore { | |||
32 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 32 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
33 | spinlock_t wait_lock; | 33 | spinlock_t wait_lock; |
34 | struct list_head wait_list; | 34 | struct list_head wait_list; |
35 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
36 | struct lockdep_map dep_map; | ||
37 | #endif | ||
35 | }; | 38 | }; |
36 | 39 | ||
40 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
41 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
42 | #else | ||
43 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
44 | #endif | ||
45 | |||
37 | #define __RWSEM_INITIALIZER(name) \ | 46 | #define __RWSEM_INITIALIZER(name) \ |
38 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ | 47 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ |
39 | LIST_HEAD_INIT((name).wait_list) } | 48 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } |
40 | 49 | ||
41 | #define DECLARE_RWSEM(name) \ | 50 | #define DECLARE_RWSEM(name) \ |
42 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | 51 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) |
@@ -46,12 +55,15 @@ extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | |||
46 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | 55 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); |
47 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | 56 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); |
48 | 57 | ||
49 | static inline void init_rwsem(struct rw_semaphore *sem) | 58 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, |
50 | { | 59 | struct lock_class_key *key); |
51 | sem->count = RWSEM_UNLOCKED_VALUE; | 60 | |
52 | spin_lock_init(&sem->wait_lock); | 61 | #define init_rwsem(sem) \ |
53 | INIT_LIST_HEAD(&sem->wait_list); | 62 | do { \ |
54 | } | 63 | static struct lock_class_key __key; \ |
64 | \ | ||
65 | __init_rwsem((sem), #sem, &__key); \ | ||
66 | } while (0) | ||
55 | 67 | ||
56 | /* | 68 | /* |
57 | * lock for reading | 69 | * lock for reading |
@@ -78,7 +90,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) | |||
78 | /* | 90 | /* |
79 | * lock for writing | 91 | * lock for writing |
80 | */ | 92 | */ |
81 | static inline void __down_write(struct rw_semaphore *sem) | 93 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) |
82 | { | 94 | { |
83 | int tmp; | 95 | int tmp; |
84 | 96 | ||
@@ -88,6 +100,11 @@ static inline void __down_write(struct rw_semaphore *sem) | |||
88 | rwsem_down_write_failed(sem); | 100 | rwsem_down_write_failed(sem); |
89 | } | 101 | } |
90 | 102 | ||
103 | static inline void __down_write(struct rw_semaphore *sem) | ||
104 | { | ||
105 | __down_write_nested(sem, 0); | ||
106 | } | ||
107 | |||
91 | static inline int __down_write_trylock(struct rw_semaphore *sem) | 108 | static inline int __down_write_trylock(struct rw_semaphore *sem) |
92 | { | 109 | { |
93 | int tmp; | 110 | int tmp; |