diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kthread.h | 2 | ||||
-rw-r--r-- | include/linux/rwlock_types.h | 8 | ||||
-rw-r--r-- | include/linux/rwsem-spinlock.h | 31 | ||||
-rw-r--r-- | include/linux/rwsem.h | 53 | ||||
-rw-r--r-- | include/linux/spinlock_types.h | 8 |
5 files changed, 54 insertions, 48 deletions
diff --git a/include/linux/kthread.h b/include/linux/kthread.h index ce0775aa64c3..7ff16f7d3ed4 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h | |||
@@ -64,7 +64,7 @@ struct kthread_work { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | #define KTHREAD_WORKER_INIT(worker) { \ | 66 | #define KTHREAD_WORKER_INIT(worker) { \ |
67 | .lock = SPIN_LOCK_UNLOCKED, \ | 67 | .lock = __SPIN_LOCK_UNLOCKED((worker).lock), \ |
68 | .work_list = LIST_HEAD_INIT((worker).work_list), \ | 68 | .work_list = LIST_HEAD_INIT((worker).work_list), \ |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h index bd31808c7d8e..cc0072e93e36 100644 --- a/include/linux/rwlock_types.h +++ b/include/linux/rwlock_types.h | |||
@@ -43,14 +43,6 @@ typedef struct { | |||
43 | RW_DEP_MAP_INIT(lockname) } | 43 | RW_DEP_MAP_INIT(lockname) } |
44 | #endif | 44 | #endif |
45 | 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) | 46 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) |
55 | 47 | ||
56 | #endif /* __LINUX_RWLOCK_TYPES_H */ | 48 | #endif /* __LINUX_RWLOCK_TYPES_H */ |
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h index bdfcc2527970..34701241b673 100644 --- a/include/linux/rwsem-spinlock.h +++ b/include/linux/rwsem-spinlock.h | |||
@@ -12,15 +12,7 @@ | |||
12 | #error "please don't include linux/rwsem-spinlock.h directly, use linux/rwsem.h instead" | 12 | #error "please don't include linux/rwsem-spinlock.h directly, use linux/rwsem.h instead" |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/list.h> | ||
17 | |||
18 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
19 | |||
20 | #include <linux/types.h> | ||
21 | |||
22 | struct rwsem_waiter; | ||
23 | |||
24 | /* | 16 | /* |
25 | * the rw-semaphore definition | 17 | * the rw-semaphore definition |
26 | * - if activity is 0 then there are no active readers or writers | 18 | * - if activity is 0 then there are no active readers or writers |
@@ -37,28 +29,7 @@ struct rw_semaphore { | |||
37 | #endif | 29 | #endif |
38 | }; | 30 | }; |
39 | 31 | ||
40 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 32 | #define RWSEM_UNLOCKED_VALUE 0x00000000 |
41 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
42 | #else | ||
43 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
44 | #endif | ||
45 | |||
46 | #define __RWSEM_INITIALIZER(name) \ | ||
47 | { 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \ | ||
48 | __RWSEM_DEP_MAP_INIT(name) } | ||
49 | |||
50 | #define DECLARE_RWSEM(name) \ | ||
51 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
52 | |||
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 | 33 | ||
63 | extern void __down_read(struct rw_semaphore *sem); | 34 | extern void __down_read(struct rw_semaphore *sem); |
64 | 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 efd348fe8ca7..a8afe9cd000c 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
@@ -11,6 +11,9 @@ | |||
11 | 11 | ||
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/list.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | |||
14 | #include <asm/system.h> | 17 | #include <asm/system.h> |
15 | #include <asm/atomic.h> | 18 | #include <asm/atomic.h> |
16 | 19 | ||
@@ -19,9 +22,57 @@ struct rw_semaphore; | |||
19 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK | 22 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK |
20 | #include <linux/rwsem-spinlock.h> /* use a generic implementation */ | 23 | #include <linux/rwsem-spinlock.h> /* use a generic implementation */ |
21 | #else | 24 | #else |
22 | #include <asm/rwsem.h> /* use an arch-specific implementation */ | 25 | /* All arch specific implementations share the same struct */ |
26 | struct rw_semaphore { | ||
27 | long count; | ||
28 | spinlock_t wait_lock; | ||
29 | struct list_head wait_list; | ||
30 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
31 | struct lockdep_map dep_map; | ||
32 | #endif | ||
33 | }; | ||
34 | |||
35 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
36 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
37 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *); | ||
38 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
39 | |||
40 | /* Include the arch specific part */ | ||
41 | #include <asm/rwsem.h> | ||
42 | |||
43 | /* In all implementations count != 0 means locked */ | ||
44 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
45 | { | ||
46 | return sem->count != 0; | ||
47 | } | ||
48 | |||
49 | #endif | ||
50 | |||
51 | /* Common initializer macros and functions */ | ||
52 | |||
53 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
54 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
55 | #else | ||
56 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
23 | #endif | 57 | #endif |
24 | 58 | ||
59 | #define __RWSEM_INITIALIZER(name) \ | ||
60 | { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED(name.wait_lock), \ | ||
61 | LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } | ||
62 | |||
63 | #define DECLARE_RWSEM(name) \ | ||
64 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
65 | |||
66 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
67 | struct lock_class_key *key); | ||
68 | |||
69 | #define init_rwsem(sem) \ | ||
70 | do { \ | ||
71 | static struct lock_class_key __key; \ | ||
72 | \ | ||
73 | __init_rwsem((sem), #sem, &__key); \ | ||
74 | } while (0) | ||
75 | |||
25 | /* | 76 | /* |
26 | * lock for reading | 77 | * lock for reading |
27 | */ | 78 | */ |
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 851b7783720d..73548eb13a5d 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h | |||
@@ -81,14 +81,6 @@ typedef struct spinlock { | |||
81 | #define __SPIN_LOCK_UNLOCKED(lockname) \ | 81 | #define __SPIN_LOCK_UNLOCKED(lockname) \ |
82 | (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname) | 82 | (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname) |
83 | 83 | ||
84 | /* | ||
85 | * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence | ||
86 | * deprecated. | ||
87 | * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as | ||
88 | * appropriate. | ||
89 | */ | ||
90 | #define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init) | ||
91 | |||
92 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) | 84 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) |
93 | 85 | ||
94 | #include <linux/rwlock_types.h> | 86 | #include <linux/rwlock_types.h> |