Rev 3243 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3243 | Rev 5272 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | # include |
15 | # include |
16 | #endif |
16 | #endif |
Line 17... | Line 17... | ||
17 | 17 | ||
Line 18... | Line 18... | ||
18 | #include |
18 | #include |
19 | 19 | ||
20 | typedef struct spinlock { |
20 | typedef struct raw_spinlock { |
21 | raw_spinlock_t raw_lock; |
21 | arch_spinlock_t raw_lock; |
22 | #ifdef CONFIG_GENERIC_LOCKBREAK |
22 | #ifdef CONFIG_GENERIC_LOCKBREAK |
23 | unsigned int break_lock; |
23 | unsigned int break_lock; |
24 | #endif |
24 | #endif |
25 | #ifdef CONFIG_DEBUG_SPINLOCK |
25 | #ifdef CONFIG_DEBUG_SPINLOCK |
26 | unsigned int magic, owner_cpu; |
26 | unsigned int magic, owner_cpu; |
27 | void *owner; |
27 | void *owner; |
28 | #endif |
28 | #endif |
29 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
29 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
30 | struct lockdep_map dep_map; |
30 | struct lockdep_map dep_map; |
Line 31... | Line 31... | ||
31 | #endif |
31 | #endif |
Line 32... | Line -... | ||
32 | } spinlock_t; |
- | |
33 | - | ||
34 | #define SPINLOCK_MAGIC 0xdead4ead |
- | |
35 | - | ||
36 | typedef struct { |
- | |
37 | raw_rwlock_t raw_lock; |
- | |
38 | #ifdef CONFIG_GENERIC_LOCKBREAK |
- | |
39 | unsigned int break_lock; |
- | |
40 | #endif |
- | |
41 | #ifdef CONFIG_DEBUG_SPINLOCK |
- | |
42 | unsigned int magic, owner_cpu; |
- | |
43 | void *owner; |
- | |
44 | #endif |
- | |
45 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
- | |
46 | struct lockdep_map dep_map; |
- | |
47 | #endif |
- | |
48 | } rwlock_t; |
32 | } raw_spinlock_t; |
Line 49... | Line 33... | ||
49 | 33 | ||
50 | #define RWLOCK_MAGIC 0xdeaf1eed |
34 | #define SPINLOCK_MAGIC 0xdead4ead |
51 | 35 | ||
52 | #define SPINLOCK_OWNER_INIT ((void *)-1L) |
36 | #define SPINLOCK_OWNER_INIT ((void *)-1L) |
53 | 37 | ||
Line 54... | Line -... | ||
54 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
- | |
55 | # define SPIN_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } |
- | |
56 | #else |
- | |
57 | # define SPIN_DEP_MAP_INIT(lockname) |
- | |
58 | #endif |
- | |
59 | - | ||
60 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
61 | # define RW_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } |
39 | # define SPIN_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } |
62 | #else |
- | |
63 | # define RW_DEP_MAP_INIT(lockname) |
40 | #else |
64 | #endif |
- | |
65 | - | ||
66 | #ifdef CONFIG_DEBUG_SPINLOCK |
- | |
67 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
- | |
68 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ |
- | |
69 | .magic = SPINLOCK_MAGIC, \ |
- | |
70 | .owner = SPINLOCK_OWNER_INIT, \ |
- | |
71 | .owner_cpu = -1, \ |
41 | # define SPIN_DEP_MAP_INIT(lockname) |
72 | SPIN_DEP_MAP_INIT(lockname) } |
42 | #endif |
73 | #define __RW_LOCK_UNLOCKED(lockname) \ |
43 | |
- | 44 | #ifdef CONFIG_DEBUG_SPINLOCK |
|
- | 45 | # define SPIN_DEBUG_INIT(lockname) \ |
|
- | 46 | .magic = SPINLOCK_MAGIC, \ |
|
74 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ |
47 | .owner_cpu = -1, \ |
- | 48 | .owner = SPINLOCK_OWNER_INIT, |
|
75 | .magic = RWLOCK_MAGIC, \ |
49 | #else |
- | 50 | # define SPIN_DEBUG_INIT(lockname) |
|
76 | .owner = SPINLOCK_OWNER_INIT, \ |
51 | #endif |
- | 52 | ||
77 | .owner_cpu = -1, \ |
53 | #define __RAW_SPIN_LOCK_INITIALIZER(lockname) \ |
- | 54 | { \ |
|
- | 55 | .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ |
|
78 | RW_DEP_MAP_INIT(lockname) } |
56 | SPIN_DEBUG_INIT(lockname) \ |
- | 57 | SPIN_DEP_MAP_INIT(lockname) } |
|
- | 58 | ||
- | 59 | #define __RAW_SPIN_LOCK_UNLOCKED(lockname) \ |
|
79 | #else |
60 | (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname) |
- | 61 | ||
- | 62 | #define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x) |
|
- | 63 | ||
- | 64 | typedef struct spinlock { |
|
- | 65 | union { |
|
- | 66 | struct raw_spinlock rlock; |
|
- | 67 | ||
80 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
68 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
- | 69 | # define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map)) |
|
- | 70 | struct { |
|
- | 71 | u8 __padding[LOCK_PADSIZE]; |
|
- | 72 | struct lockdep_map dep_map; |
|
- | 73 | }; |
|
Line 81... | Line -... | ||
81 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ |
- | |
82 | SPIN_DEP_MAP_INIT(lockname) } |
- | |
83 | #define __RW_LOCK_UNLOCKED(lockname) \ |
- | |
84 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ |
- | |
85 | RW_DEP_MAP_INIT(lockname) } |
- | |
86 | #endif |
- | |
87 | 74 | #endif |
|
88 | /* |
75 | }; |
Line 89... | Line 76... | ||
89 | * SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and |
76 | } spinlock_t; |
- | 77 | ||
90 | * are hence deprecated. |
78 | #define __SPIN_LOCK_INITIALIZER(lockname) \ |
Line 91... | Line 79... | ||
91 | * Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or |
79 | { { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } } |