diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:28:30 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 21:28:30 -0400 |
| commit | 0586bed3e8563c2eb89bc7256e30ce633ae06cfb (patch) | |
| tree | 7a59610f45f7222f25b3212c53fa28636bb4427c /arch | |
| parent | b80cd62b7d4406bbe8c573fe4381dcc71a2850fd (diff) | |
| parent | dbebbfbb1605f0179e7c0d900d941cc9c45de569 (diff) | |
Merge branch 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
rtmutex: tester: Remove the remaining BKL leftovers
lockdep/timers: Explain in detail the locking problems del_timer_sync() may cause
rtmutex: Simplify PI algorithm and make highest prio task get lock
rwsem: Remove redundant asmregparm annotation
rwsem: Move duplicate function prototypes to linux/rwsem.h
rwsem: Unify the duplicate rwsem_is_locked() inlines
rwsem: Move duplicate init macros and functions to linux/rwsem.h
rwsem: Move duplicate struct rwsem declaration to linux/rwsem.h
x86: Cleanup rwsem_count_t typedef
rwsem: Cleanup includes
locking: Remove deprecated lock initializers
cred: Replace deprecated spinlock initialization
kthread: Replace deprecated spinlock initialization
xtensa: Replace deprecated spinlock initialization
um: Replace deprecated spinlock initialization
sparc: Replace deprecated spinlock initialization
mips: Replace deprecated spinlock initialization
cris: Replace deprecated spinlock initialization
alpha: Replace deprecated spinlock initialization
rtmutex-tester: Remove BKL tests
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/alpha/include/asm/rwsem.h | 36 | ||||
| -rw-r--r-- | arch/cris/arch-v32/kernel/smp.c | 4 | ||||
| -rw-r--r-- | arch/ia64/include/asm/rwsem.h | 37 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/rwsem.h | 51 | ||||
| -rw-r--r-- | arch/s390/include/asm/rwsem.h | 63 | ||||
| -rw-r--r-- | arch/sh/include/asm/rwsem.h | 56 | ||||
| -rw-r--r-- | arch/sparc/include/asm/rwsem.h | 46 | ||||
| -rw-r--r-- | arch/sparc/lib/atomic32.c | 2 | ||||
| -rw-r--r-- | arch/um/drivers/ubd_kern.c | 2 | ||||
| -rw-r--r-- | arch/x86/include/asm/rwsem.h | 80 | ||||
| -rw-r--r-- | arch/xtensa/include/asm/rwsem.h | 37 |
11 files changed, 14 insertions, 400 deletions
diff --git a/arch/alpha/include/asm/rwsem.h b/arch/alpha/include/asm/rwsem.h index 1570c0b5433..a83bbea62c6 100644 --- a/arch/alpha/include/asm/rwsem.h +++ b/arch/alpha/include/asm/rwsem.h | |||
| @@ -13,44 +13,13 @@ | |||
| 13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
| 14 | 14 | ||
| 15 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
| 16 | #include <linux/list.h> | ||
| 17 | #include <linux/spinlock.h> | ||
| 18 | 16 | ||
| 19 | struct rwsem_waiter; | ||
| 20 | |||
| 21 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 22 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 23 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *); | ||
| 24 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 25 | |||
| 26 | /* | ||
| 27 | * the semaphore definition | ||
| 28 | */ | ||
| 29 | struct rw_semaphore { | ||
| 30 | long count; | ||
| 31 | #define RWSEM_UNLOCKED_VALUE 0x0000000000000000L | 17 | #define RWSEM_UNLOCKED_VALUE 0x0000000000000000L |
| 32 | #define RWSEM_ACTIVE_BIAS 0x0000000000000001L | 18 | #define RWSEM_ACTIVE_BIAS 0x0000000000000001L |
| 33 | #define RWSEM_ACTIVE_MASK 0x00000000ffffffffL | 19 | #define RWSEM_ACTIVE_MASK 0x00000000ffffffffL |
| 34 | #define RWSEM_WAITING_BIAS (-0x0000000100000000L) | 20 | #define RWSEM_WAITING_BIAS (-0x0000000100000000L) |
| 35 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 21 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 36 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 22 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 37 | spinlock_t wait_lock; | ||
| 38 | struct list_head wait_list; | ||
| 39 | }; | ||
| 40 | |||
| 41 | #define __RWSEM_INITIALIZER(name) \ | ||
| 42 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ | ||
| 43 | LIST_HEAD_INIT((name).wait_list) } | ||
| 44 | |||
| 45 | #define DECLARE_RWSEM(name) \ | ||
| 46 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 47 | |||
| 48 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
| 49 | { | ||
| 50 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 51 | spin_lock_init(&sem->wait_lock); | ||
| 52 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 53 | } | ||
| 54 | 23 | ||
| 55 | static inline void __down_read(struct rw_semaphore *sem) | 24 | static inline void __down_read(struct rw_semaphore *sem) |
| 56 | { | 25 | { |
| @@ -250,10 +219,5 @@ static inline long rwsem_atomic_update(long val, struct rw_semaphore *sem) | |||
| 250 | #endif | 219 | #endif |
| 251 | } | 220 | } |
| 252 | 221 | ||
| 253 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 254 | { | ||
| 255 | return (sem->count != 0); | ||
| 256 | } | ||
| 257 | |||
| 258 | #endif /* __KERNEL__ */ | 222 | #endif /* __KERNEL__ */ |
| 259 | #endif /* _ALPHA_RWSEM_H */ | 223 | #endif /* _ALPHA_RWSEM_H */ |
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c index 84fed3b4b07..4c9e3e1ba5d 100644 --- a/arch/cris/arch-v32/kernel/smp.c +++ b/arch/cris/arch-v32/kernel/smp.c | |||
| @@ -26,7 +26,9 @@ | |||
| 26 | #define FLUSH_ALL (void*)0xffffffff | 26 | #define FLUSH_ALL (void*)0xffffffff |
| 27 | 27 | ||
| 28 | /* Vector of locks used for various atomic operations */ | 28 | /* Vector of locks used for various atomic operations */ |
| 29 | spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] = SPIN_LOCK_UNLOCKED}; | 29 | spinlock_t cris_atomic_locks[] = { |
| 30 | [0 ... LOCK_COUNT - 1] = __SPIN_LOCK_UNLOCKED(cris_atomic_locks) | ||
| 31 | }; | ||
| 30 | 32 | ||
| 31 | /* CPU masks */ | 33 | /* CPU masks */ |
| 32 | cpumask_t phys_cpu_present_map = CPU_MASK_NONE; | 34 | cpumask_t phys_cpu_present_map = CPU_MASK_NONE; |
diff --git a/arch/ia64/include/asm/rwsem.h b/arch/ia64/include/asm/rwsem.h index 215d5454c7d..3027e7516d8 100644 --- a/arch/ia64/include/asm/rwsem.h +++ b/arch/ia64/include/asm/rwsem.h | |||
| @@ -25,20 +25,8 @@ | |||
| 25 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." | 25 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #include <linux/list.h> | ||
| 29 | #include <linux/spinlock.h> | ||
| 30 | |||
| 31 | #include <asm/intrinsics.h> | 28 | #include <asm/intrinsics.h> |
| 32 | 29 | ||
| 33 | /* | ||
| 34 | * the semaphore definition | ||
| 35 | */ | ||
| 36 | struct rw_semaphore { | ||
| 37 | signed long count; | ||
| 38 | spinlock_t wait_lock; | ||
| 39 | struct list_head wait_list; | ||
| 40 | }; | ||
| 41 | |||
| 42 | #define RWSEM_UNLOCKED_VALUE __IA64_UL_CONST(0x0000000000000000) | 30 | #define RWSEM_UNLOCKED_VALUE __IA64_UL_CONST(0x0000000000000000) |
| 43 | #define RWSEM_ACTIVE_BIAS (1L) | 31 | #define RWSEM_ACTIVE_BIAS (1L) |
| 44 | #define RWSEM_ACTIVE_MASK (0xffffffffL) | 32 | #define RWSEM_ACTIVE_MASK (0xffffffffL) |
| @@ -46,26 +34,6 @@ struct rw_semaphore { | |||
| 46 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 34 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 47 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 35 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 48 | 36 | ||
| 49 | #define __RWSEM_INITIALIZER(name) \ | ||
| 50 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
| 51 | LIST_HEAD_INIT((name).wait_list) } | ||
| 52 | |||
| 53 | #define DECLARE_RWSEM(name) \ | ||
| 54 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 55 | |||
| 56 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 57 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 58 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
| 59 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 60 | |||
| 61 | static inline void | ||
| 62 | init_rwsem (struct rw_semaphore *sem) | ||
| 63 | { | ||
| 64 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 65 | spin_lock_init(&sem->wait_lock); | ||
| 66 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 67 | } | ||
| 68 | |||
| 69 | /* | 37 | /* |
| 70 | * lock for reading | 38 | * lock for reading |
| 71 | */ | 39 | */ |
| @@ -174,9 +142,4 @@ __downgrade_write (struct rw_semaphore *sem) | |||
| 174 | #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) | 142 | #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) |
| 175 | #define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) | 143 | #define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) |
| 176 | 144 | ||
| 177 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 178 | { | ||
| 179 | return (sem->count != 0); | ||
| 180 | } | ||
| 181 | |||
| 182 | #endif /* _ASM_IA64_RWSEM_H */ | 145 | #endif /* _ASM_IA64_RWSEM_H */ |
diff --git a/arch/powerpc/include/asm/rwsem.h b/arch/powerpc/include/asm/rwsem.h index 8447d89fbe7..bb1e2cdeb9b 100644 --- a/arch/powerpc/include/asm/rwsem.h +++ b/arch/powerpc/include/asm/rwsem.h | |||
| @@ -13,11 +13,6 @@ | |||
| 13 | * by Paul Mackerras <paulus@samba.org>. | 13 | * by Paul Mackerras <paulus@samba.org>. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include <linux/list.h> | ||
| 17 | #include <linux/spinlock.h> | ||
| 18 | #include <asm/atomic.h> | ||
| 19 | #include <asm/system.h> | ||
| 20 | |||
| 21 | /* | 16 | /* |
| 22 | * the semaphore definition | 17 | * the semaphore definition |
| 23 | */ | 18 | */ |
| @@ -33,47 +28,6 @@ | |||
| 33 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 28 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 34 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 29 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 35 | 30 | ||
| 36 | struct rw_semaphore { | ||
| 37 | long count; | ||
| 38 | spinlock_t wait_lock; | ||
| 39 | struct list_head wait_list; | ||
| 40 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 41 | struct lockdep_map dep_map; | ||
| 42 | #endif | ||
| 43 | }; | ||
| 44 | |||
| 45 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 46 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
| 47 | #else | ||
| 48 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #define __RWSEM_INITIALIZER(name) \ | ||
| 52 | { \ | ||
| 53 | RWSEM_UNLOCKED_VALUE, \ | ||
| 54 | __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
| 55 | LIST_HEAD_INIT((name).wait_list) \ | ||
| 56 | __RWSEM_DEP_MAP_INIT(name) \ | ||
| 57 | } | ||
| 58 | |||
| 59 | #define DECLARE_RWSEM(name) \ | ||
| 60 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 61 | |||
| 62 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 63 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 64 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
| 65 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 66 | |||
| 67 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
| 68 | struct lock_class_key *key); | ||
| 69 | |||
| 70 | #define init_rwsem(sem) \ | ||
| 71 | do { \ | ||
| 72 | static struct lock_class_key __key; \ | ||
| 73 | \ | ||
| 74 | __init_rwsem((sem), #sem, &__key); \ | ||
| 75 | } while (0) | ||
| 76 | |||
| 77 | /* | 31 | /* |
| 78 | * lock for reading | 32 | * lock for reading |
| 79 | */ | 33 | */ |
| @@ -174,10 +128,5 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) | |||
| 174 | return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); | 128 | return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); |
| 175 | } | 129 | } |
| 176 | 130 | ||
| 177 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 178 | { | ||
| 179 | return sem->count != 0; | ||
| 180 | } | ||
| 181 | |||
| 182 | #endif /* __KERNEL__ */ | 131 | #endif /* __KERNEL__ */ |
| 183 | #endif /* _ASM_POWERPC_RWSEM_H */ | 132 | #endif /* _ASM_POWERPC_RWSEM_H */ |
diff --git a/arch/s390/include/asm/rwsem.h b/arch/s390/include/asm/rwsem.h index 423fdda2322..d0eb4653ceb 100644 --- a/arch/s390/include/asm/rwsem.h +++ b/arch/s390/include/asm/rwsem.h | |||
| @@ -43,29 +43,6 @@ | |||
| 43 | 43 | ||
| 44 | #ifdef __KERNEL__ | 44 | #ifdef __KERNEL__ |
| 45 | 45 | ||
| 46 | #include <linux/list.h> | ||
| 47 | #include <linux/spinlock.h> | ||
| 48 | |||
| 49 | struct rwsem_waiter; | ||
| 50 | |||
| 51 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *); | ||
| 52 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *); | ||
| 53 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *); | ||
| 54 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *); | ||
| 55 | extern struct rw_semaphore *rwsem_downgrade_write(struct rw_semaphore *); | ||
| 56 | |||
| 57 | /* | ||
| 58 | * the semaphore definition | ||
| 59 | */ | ||
| 60 | struct rw_semaphore { | ||
| 61 | signed long count; | ||
| 62 | spinlock_t wait_lock; | ||
| 63 | struct list_head wait_list; | ||
| 64 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 65 | struct lockdep_map dep_map; | ||
| 66 | #endif | ||
| 67 | }; | ||
| 68 | |||
| 69 | #ifndef __s390x__ | 46 | #ifndef __s390x__ |
| 70 | #define RWSEM_UNLOCKED_VALUE 0x00000000 | 47 | #define RWSEM_UNLOCKED_VALUE 0x00000000 |
| 71 | #define RWSEM_ACTIVE_BIAS 0x00000001 | 48 | #define RWSEM_ACTIVE_BIAS 0x00000001 |
| @@ -81,41 +58,6 @@ struct rw_semaphore { | |||
| 81 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 58 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 82 | 59 | ||
| 83 | /* | 60 | /* |
| 84 | * initialisation | ||
| 85 | */ | ||
| 86 | |||
| 87 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 88 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
| 89 | #else | ||
| 90 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
| 91 | #endif | ||
| 92 | |||
| 93 | #define __RWSEM_INITIALIZER(name) \ | ||
| 94 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait.lock), \ | ||
| 95 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
| 96 | |||
| 97 | #define DECLARE_RWSEM(name) \ | ||
| 98 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 99 | |||
| 100 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
| 101 | { | ||
| 102 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 103 | spin_lock_init(&sem->wait_lock); | ||
| 104 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 105 | } | ||
| 106 | |||
| 107 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
| 108 | struct lock_class_key *key); | ||
| 109 | |||
| 110 | #define init_rwsem(sem) \ | ||
| 111 | do { \ | ||
| 112 | static struct lock_class_key __key; \ | ||
| 113 | \ | ||
| 114 | __init_rwsem((sem), #sem, &__key); \ | ||
| 115 | } while (0) | ||
| 116 | |||
| 117 | |||
| 118 | /* | ||
| 119 | * lock for reading | 61 | * lock for reading |
| 120 | */ | 62 | */ |
| 121 | static inline void __down_read(struct rw_semaphore *sem) | 63 | static inline void __down_read(struct rw_semaphore *sem) |
| @@ -377,10 +319,5 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) | |||
| 377 | return new; | 319 | return new; |
| 378 | } | 320 | } |
| 379 | 321 | ||
| 380 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 381 | { | ||
| 382 | return (sem->count != 0); | ||
| 383 | } | ||
| 384 | |||
| 385 | #endif /* __KERNEL__ */ | 322 | #endif /* __KERNEL__ */ |
| 386 | #endif /* _S390_RWSEM_H */ | 323 | #endif /* _S390_RWSEM_H */ |
diff --git a/arch/sh/include/asm/rwsem.h b/arch/sh/include/asm/rwsem.h index 06e2251a5e4..edab5726529 100644 --- a/arch/sh/include/asm/rwsem.h +++ b/arch/sh/include/asm/rwsem.h | |||
| @@ -11,64 +11,13 @@ | |||
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
| 14 | #include <linux/list.h> | ||
| 15 | #include <linux/spinlock.h> | ||
| 16 | #include <asm/atomic.h> | ||
| 17 | #include <asm/system.h> | ||
| 18 | 14 | ||
| 19 | /* | ||
| 20 | * the semaphore definition | ||
| 21 | */ | ||
| 22 | struct rw_semaphore { | ||
| 23 | long count; | ||
| 24 | #define RWSEM_UNLOCKED_VALUE 0x00000000 | 15 | #define RWSEM_UNLOCKED_VALUE 0x00000000 |
| 25 | #define RWSEM_ACTIVE_BIAS 0x00000001 | 16 | #define RWSEM_ACTIVE_BIAS 0x00000001 |
| 26 | #define RWSEM_ACTIVE_MASK 0x0000ffff | 17 | #define RWSEM_ACTIVE_MASK 0x0000ffff |
| 27 | #define RWSEM_WAITING_BIAS (-0x00010000) | 18 | #define RWSEM_WAITING_BIAS (-0x00010000) |
| 28 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 19 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 29 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 20 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 30 | spinlock_t wait_lock; | ||
| 31 | struct list_head wait_list; | ||
| 32 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 33 | struct lockdep_map dep_map; | ||
| 34 | #endif | ||
| 35 | }; | ||
| 36 | |||
| 37 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 38 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
| 39 | #else | ||
| 40 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #define __RWSEM_INITIALIZER(name) \ | ||
| 44 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
| 45 | LIST_HEAD_INIT((name).wait_list) \ | ||
| 46 | __RWSEM_DEP_MAP_INIT(name) } | ||
| 47 | |||
| 48 | #define DECLARE_RWSEM(name) \ | ||
| 49 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 50 | |||
| 51 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 52 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 53 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
| 54 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 55 | |||
| 56 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
| 57 | struct lock_class_key *key); | ||
| 58 | |||
| 59 | #define init_rwsem(sem) \ | ||
| 60 | do { \ | ||
| 61 | static struct lock_class_key __key; \ | ||
| 62 | \ | ||
| 63 | __init_rwsem((sem), #sem, &__key); \ | ||
| 64 | } while (0) | ||
| 65 | |||
| 66 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
| 67 | { | ||
| 68 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 69 | spin_lock_init(&sem->wait_lock); | ||
| 70 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 71 | } | ||
| 72 | 21 | ||
| 73 | /* | 22 | /* |
| 74 | * lock for reading | 23 | * lock for reading |
| @@ -179,10 +128,5 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | |||
| 179 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | 128 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); |
| 180 | } | 129 | } |
| 181 | 130 | ||
| 182 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 183 | { | ||
| 184 | return (sem->count != 0); | ||
| 185 | } | ||
| 186 | |||
| 187 | #endif /* __KERNEL__ */ | 131 | #endif /* __KERNEL__ */ |
| 188 | #endif /* _ASM_SH_RWSEM_H */ | 132 | #endif /* _ASM_SH_RWSEM_H */ |
diff --git a/arch/sparc/include/asm/rwsem.h b/arch/sparc/include/asm/rwsem.h index a2b4302869b..069bf4d663a 100644 --- a/arch/sparc/include/asm/rwsem.h +++ b/arch/sparc/include/asm/rwsem.h | |||
| @@ -13,53 +13,12 @@ | |||
| 13 | 13 | ||
| 14 | #ifdef __KERNEL__ | 14 | #ifdef __KERNEL__ |
| 15 | 15 | ||
| 16 | #include <linux/list.h> | ||
| 17 | #include <linux/spinlock.h> | ||
| 18 | |||
| 19 | struct rwsem_waiter; | ||
| 20 | |||
| 21 | struct rw_semaphore { | ||
| 22 | signed long count; | ||
| 23 | #define RWSEM_UNLOCKED_VALUE 0x00000000L | 16 | #define RWSEM_UNLOCKED_VALUE 0x00000000L |
| 24 | #define RWSEM_ACTIVE_BIAS 0x00000001L | 17 | #define RWSEM_ACTIVE_BIAS 0x00000001L |
| 25 | #define RWSEM_ACTIVE_MASK 0xffffffffL | 18 | #define RWSEM_ACTIVE_MASK 0xffffffffL |
| 26 | #define RWSEM_WAITING_BIAS (-RWSEM_ACTIVE_MASK-1) | 19 | #define RWSEM_WAITING_BIAS (-RWSEM_ACTIVE_MASK-1) |
| 27 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 20 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 28 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 21 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 29 | spinlock_t wait_lock; | ||
| 30 | struct list_head wait_list; | ||
| 31 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 32 | struct lockdep_map dep_map; | ||
| 33 | #endif | ||
| 34 | }; | ||
| 35 | |||
| 36 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 37 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
| 38 | #else | ||
| 39 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #define __RWSEM_INITIALIZER(name) \ | ||
| 43 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
| 44 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
| 45 | |||
| 46 | #define DECLARE_RWSEM(name) \ | ||
| 47 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 48 | |||
| 49 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 50 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 51 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
| 52 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 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 | 22 | ||
| 64 | /* | 23 | /* |
| 65 | * lock for reading | 24 | * lock for reading |
| @@ -160,11 +119,6 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) | |||
| 160 | return atomic64_add_return(delta, (atomic64_t *)(&sem->count)); | 119 | return atomic64_add_return(delta, (atomic64_t *)(&sem->count)); |
| 161 | } | 120 | } |
| 162 | 121 | ||
| 163 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 164 | { | ||
| 165 | return (sem->count != 0); | ||
| 166 | } | ||
| 167 | |||
| 168 | #endif /* __KERNEL__ */ | 122 | #endif /* __KERNEL__ */ |
| 169 | 123 | ||
| 170 | #endif /* _SPARC64_RWSEM_H */ | 124 | #endif /* _SPARC64_RWSEM_H */ |
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index cbddeb38ffd..d3c7a12ad87 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #define ATOMIC_HASH(a) (&__atomic_hash[(((unsigned long)a)>>8) & (ATOMIC_HASH_SIZE-1)]) | 16 | #define ATOMIC_HASH(a) (&__atomic_hash[(((unsigned long)a)>>8) & (ATOMIC_HASH_SIZE-1)]) |
| 17 | 17 | ||
| 18 | spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] = { | 18 | spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] = { |
| 19 | [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED | 19 | [0 ... (ATOMIC_HASH_SIZE-1)] = __SPIN_LOCK_UNLOCKED(__atomic_hash) |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | #else /* SMP */ | 22 | #else /* SMP */ |
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index ba4a98ba39c..620f5b70957 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
| @@ -185,7 +185,7 @@ struct ubd { | |||
| 185 | .no_cow = 0, \ | 185 | .no_cow = 0, \ |
| 186 | .shared = 0, \ | 186 | .shared = 0, \ |
| 187 | .cow = DEFAULT_COW, \ | 187 | .cow = DEFAULT_COW, \ |
| 188 | .lock = SPIN_LOCK_UNLOCKED, \ | 188 | .lock = __SPIN_LOCK_UNLOCKED(ubd_devs.lock), \ |
| 189 | .request = NULL, \ | 189 | .request = NULL, \ |
| 190 | .start_sg = 0, \ | 190 | .start_sg = 0, \ |
| 191 | .end_sg = 0, \ | 191 | .end_sg = 0, \ |
diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h index d1e41b0f9b6..df4cd32b4cc 100644 --- a/arch/x86/include/asm/rwsem.h +++ b/arch/x86/include/asm/rwsem.h | |||
| @@ -37,26 +37,9 @@ | |||
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #ifdef __KERNEL__ | 39 | #ifdef __KERNEL__ |
| 40 | |||
| 41 | #include <linux/list.h> | ||
| 42 | #include <linux/spinlock.h> | ||
| 43 | #include <linux/lockdep.h> | ||
| 44 | #include <asm/asm.h> | 40 | #include <asm/asm.h> |
| 45 | 41 | ||
| 46 | struct rwsem_waiter; | ||
| 47 | |||
| 48 | extern asmregparm struct rw_semaphore * | ||
| 49 | rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 50 | extern asmregparm struct rw_semaphore * | ||
| 51 | rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 52 | extern asmregparm struct rw_semaphore * | ||
| 53 | rwsem_wake(struct rw_semaphore *); | ||
| 54 | extern asmregparm struct rw_semaphore * | ||
| 55 | rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 56 | |||
| 57 | /* | 42 | /* |
| 58 | * the semaphore definition | ||
| 59 | * | ||
| 60 | * The bias values and the counter type limits the number of | 43 | * The bias values and the counter type limits the number of |
| 61 | * potential readers/writers to 32767 for 32 bits and 2147483647 | 44 | * potential readers/writers to 32767 for 32 bits and 2147483647 |
| 62 | * for 64 bits. | 45 | * for 64 bits. |
| @@ -74,43 +57,6 @@ extern asmregparm struct rw_semaphore * | |||
| 74 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 57 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 75 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 58 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 76 | 59 | ||
| 77 | typedef signed long rwsem_count_t; | ||
| 78 | |||
| 79 | struct rw_semaphore { | ||
| 80 | rwsem_count_t count; | ||
| 81 | spinlock_t wait_lock; | ||
| 82 | struct list_head wait_list; | ||
| 83 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 84 | struct lockdep_map dep_map; | ||
| 85 | #endif | ||
| 86 | }; | ||
| 87 | |||
| 88 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 89 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
| 90 | #else | ||
| 91 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
| 92 | #endif | ||
| 93 | |||
| 94 | |||
| 95 | #define __RWSEM_INITIALIZER(name) \ | ||
| 96 | { \ | ||
| 97 | RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ | ||
| 98 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) \ | ||
| 99 | } | ||
| 100 | |||
| 101 | #define DECLARE_RWSEM(name) \ | ||
| 102 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 103 | |||
| 104 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
| 105 | struct lock_class_key *key); | ||
| 106 | |||
| 107 | #define init_rwsem(sem) \ | ||
| 108 | do { \ | ||
| 109 | static struct lock_class_key __key; \ | ||
| 110 | \ | ||
| 111 | __init_rwsem((sem), #sem, &__key); \ | ||
| 112 | } while (0) | ||
| 113 | |||
| 114 | /* | 60 | /* |
| 115 | * lock for reading | 61 | * lock for reading |
| 116 | */ | 62 | */ |
| @@ -133,7 +79,7 @@ static inline void __down_read(struct rw_semaphore *sem) | |||
| 133 | */ | 79 | */ |
| 134 | static inline int __down_read_trylock(struct rw_semaphore *sem) | 80 | static inline int __down_read_trylock(struct rw_semaphore *sem) |
| 135 | { | 81 | { |
| 136 | rwsem_count_t result, tmp; | 82 | long result, tmp; |
| 137 | asm volatile("# beginning __down_read_trylock\n\t" | 83 | asm volatile("# beginning __down_read_trylock\n\t" |
| 138 | " mov %0,%1\n\t" | 84 | " mov %0,%1\n\t" |
| 139 | "1:\n\t" | 85 | "1:\n\t" |
| @@ -155,7 +101,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) | |||
| 155 | */ | 101 | */ |
| 156 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) | 102 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) |
| 157 | { | 103 | { |
| 158 | rwsem_count_t tmp; | 104 | long tmp; |
| 159 | asm volatile("# beginning down_write\n\t" | 105 | asm volatile("# beginning down_write\n\t" |
| 160 | LOCK_PREFIX " xadd %1,(%2)\n\t" | 106 | LOCK_PREFIX " xadd %1,(%2)\n\t" |
| 161 | /* adds 0xffff0001, returns the old value */ | 107 | /* adds 0xffff0001, returns the old value */ |
| @@ -180,9 +126,8 @@ static inline void __down_write(struct rw_semaphore *sem) | |||
| 180 | */ | 126 | */ |
| 181 | static inline int __down_write_trylock(struct rw_semaphore *sem) | 127 | static inline int __down_write_trylock(struct rw_semaphore *sem) |
| 182 | { | 128 | { |
| 183 | rwsem_count_t ret = cmpxchg(&sem->count, | 129 | long ret = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE, |
| 184 | RWSEM_UNLOCKED_VALUE, | 130 | RWSEM_ACTIVE_WRITE_BIAS); |
| 185 | RWSEM_ACTIVE_WRITE_BIAS); | ||
| 186 | if (ret == RWSEM_UNLOCKED_VALUE) | 131 | if (ret == RWSEM_UNLOCKED_VALUE) |
| 187 | return 1; | 132 | return 1; |
| 188 | return 0; | 133 | return 0; |
| @@ -193,7 +138,7 @@ static inline int __down_write_trylock(struct rw_semaphore *sem) | |||
| 193 | */ | 138 | */ |
| 194 | static inline void __up_read(struct rw_semaphore *sem) | 139 | static inline void __up_read(struct rw_semaphore *sem) |
| 195 | { | 140 | { |
| 196 | rwsem_count_t tmp; | 141 | long tmp; |
| 197 | asm volatile("# beginning __up_read\n\t" | 142 | asm volatile("# beginning __up_read\n\t" |
| 198 | LOCK_PREFIX " xadd %1,(%2)\n\t" | 143 | LOCK_PREFIX " xadd %1,(%2)\n\t" |
| 199 | /* subtracts 1, returns the old value */ | 144 | /* subtracts 1, returns the old value */ |
| @@ -211,7 +156,7 @@ static inline void __up_read(struct rw_semaphore *sem) | |||
| 211 | */ | 156 | */ |
| 212 | static inline void __up_write(struct rw_semaphore *sem) | 157 | static inline void __up_write(struct rw_semaphore *sem) |
| 213 | { | 158 | { |
| 214 | rwsem_count_t tmp; | 159 | long tmp; |
| 215 | asm volatile("# beginning __up_write\n\t" | 160 | asm volatile("# beginning __up_write\n\t" |
| 216 | LOCK_PREFIX " xadd %1,(%2)\n\t" | 161 | LOCK_PREFIX " xadd %1,(%2)\n\t" |
| 217 | /* subtracts 0xffff0001, returns the old value */ | 162 | /* subtracts 0xffff0001, returns the old value */ |
| @@ -247,8 +192,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem) | |||
| 247 | /* | 192 | /* |
| 248 | * implement atomic add functionality | 193 | * implement atomic add functionality |
| 249 | */ | 194 | */ |
| 250 | static inline void rwsem_atomic_add(rwsem_count_t delta, | 195 | static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem) |
| 251 | struct rw_semaphore *sem) | ||
| 252 | { | 196 | { |
| 253 | asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0" | 197 | asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0" |
| 254 | : "+m" (sem->count) | 198 | : "+m" (sem->count) |
| @@ -258,10 +202,9 @@ static inline void rwsem_atomic_add(rwsem_count_t delta, | |||
| 258 | /* | 202 | /* |
| 259 | * implement exchange and add functionality | 203 | * implement exchange and add functionality |
| 260 | */ | 204 | */ |
| 261 | static inline rwsem_count_t rwsem_atomic_update(rwsem_count_t delta, | 205 | static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) |
| 262 | struct rw_semaphore *sem) | ||
| 263 | { | 206 | { |
| 264 | rwsem_count_t tmp = delta; | 207 | long tmp = delta; |
| 265 | 208 | ||
| 266 | asm volatile(LOCK_PREFIX "xadd %0,%1" | 209 | asm volatile(LOCK_PREFIX "xadd %0,%1" |
| 267 | : "+r" (tmp), "+m" (sem->count) | 210 | : "+r" (tmp), "+m" (sem->count) |
| @@ -270,10 +213,5 @@ static inline rwsem_count_t rwsem_atomic_update(rwsem_count_t delta, | |||
| 270 | return tmp + delta; | 213 | return tmp + delta; |
| 271 | } | 214 | } |
| 272 | 215 | ||
| 273 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 274 | { | ||
| 275 | return (sem->count != 0); | ||
| 276 | } | ||
| 277 | |||
| 278 | #endif /* __KERNEL__ */ | 216 | #endif /* __KERNEL__ */ |
| 279 | #endif /* _ASM_X86_RWSEM_H */ | 217 | #endif /* _ASM_X86_RWSEM_H */ |
diff --git a/arch/xtensa/include/asm/rwsem.h b/arch/xtensa/include/asm/rwsem.h index e39edf5c86f..249619e7e7f 100644 --- a/arch/xtensa/include/asm/rwsem.h +++ b/arch/xtensa/include/asm/rwsem.h | |||
| @@ -17,44 +17,12 @@ | |||
| 17 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." | 17 | #error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead." |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | #include <linux/list.h> | ||
| 21 | #include <linux/spinlock.h> | ||
| 22 | #include <asm/atomic.h> | ||
| 23 | #include <asm/system.h> | ||
| 24 | |||
| 25 | /* | ||
| 26 | * the semaphore definition | ||
| 27 | */ | ||
| 28 | struct rw_semaphore { | ||
| 29 | signed long count; | ||
| 30 | #define RWSEM_UNLOCKED_VALUE 0x00000000 | 20 | #define RWSEM_UNLOCKED_VALUE 0x00000000 |
| 31 | #define RWSEM_ACTIVE_BIAS 0x00000001 | 21 | #define RWSEM_ACTIVE_BIAS 0x00000001 |
| 32 | #define RWSEM_ACTIVE_MASK 0x0000ffff | 22 | #define RWSEM_ACTIVE_MASK 0x0000ffff |
| 33 | #define RWSEM_WAITING_BIAS (-0x00010000) | 23 | #define RWSEM_WAITING_BIAS (-0x00010000) |
| 34 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | 24 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 35 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | 25 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 36 | spinlock_t wait_lock; | ||
| 37 | struct list_head wait_list; | ||
| 38 | }; | ||
| 39 | |||
| 40 | #define __RWSEM_INITIALIZER(name) \ | ||
| 41 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ | ||
| 42 | LIST_HEAD_INIT((name).wait_list) } | ||
| 43 | |||
| 44 | #define DECLARE_RWSEM(name) \ | ||
| 45 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
| 46 | |||
| 47 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
| 48 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
| 49 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
| 50 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
| 51 | |||
| 52 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
| 53 | { | ||
| 54 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
| 55 | spin_lock_init(&sem->wait_lock); | ||
| 56 | INIT_LIST_HEAD(&sem->wait_list); | ||
| 57 | } | ||
| 58 | 26 | ||
| 59 | /* | 27 | /* |
| 60 | * lock for reading | 28 | * lock for reading |
| @@ -160,9 +128,4 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | |||
| 160 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | 128 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); |
| 161 | } | 129 | } |
| 162 | 130 | ||
| 163 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
| 164 | { | ||
| 165 | return (sem->count != 0); | ||
| 166 | } | ||
| 167 | |||
| 168 | #endif /* _XTENSA_RWSEM_H */ | 131 | #endif /* _XTENSA_RWSEM_H */ |
