diff options
Diffstat (limited to 'include/asm-generic/qrwlock.h')
-rw-r--r-- | include/asm-generic/qrwlock.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h index 54a8e65e18b6..7d026bf27713 100644 --- a/include/asm-generic/qrwlock.h +++ b/include/asm-generic/qrwlock.h | |||
@@ -25,7 +25,20 @@ | |||
25 | #include <asm-generic/qrwlock_types.h> | 25 | #include <asm-generic/qrwlock_types.h> |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * Writer states & reader shift and bias | 28 | * Writer states & reader shift and bias. |
29 | * | ||
30 | * | +0 | +1 | +2 | +3 | | ||
31 | * ----+----+----+----+----+ | ||
32 | * LE | 78 | 56 | 34 | 12 | 0x12345678 | ||
33 | * ----+----+----+----+----+ | ||
34 | * | wr | rd | | ||
35 | * +----+----+----+----+ | ||
36 | * | ||
37 | * ----+----+----+----+----+ | ||
38 | * BE | 12 | 34 | 56 | 78 | 0x12345678 | ||
39 | * ----+----+----+----+----+ | ||
40 | * | rd | wr | | ||
41 | * +----+----+----+----+ | ||
29 | */ | 42 | */ |
30 | #define _QW_WAITING 1 /* A writer is waiting */ | 43 | #define _QW_WAITING 1 /* A writer is waiting */ |
31 | #define _QW_LOCKED 0xff /* A writer holds the lock */ | 44 | #define _QW_LOCKED 0xff /* A writer holds the lock */ |
@@ -134,12 +147,22 @@ static inline void queued_read_unlock(struct qrwlock *lock) | |||
134 | } | 147 | } |
135 | 148 | ||
136 | /** | 149 | /** |
150 | * __qrwlock_write_byte - retrieve the write byte address of a queue rwlock | ||
151 | * @lock : Pointer to queue rwlock structure | ||
152 | * Return: the write byte address of a queue rwlock | ||
153 | */ | ||
154 | static inline u8 *__qrwlock_write_byte(struct qrwlock *lock) | ||
155 | { | ||
156 | return (u8 *)lock + 3 * IS_BUILTIN(CONFIG_CPU_BIG_ENDIAN); | ||
157 | } | ||
158 | |||
159 | /** | ||
137 | * queued_write_unlock - release write lock of a queue rwlock | 160 | * queued_write_unlock - release write lock of a queue rwlock |
138 | * @lock : Pointer to queue rwlock structure | 161 | * @lock : Pointer to queue rwlock structure |
139 | */ | 162 | */ |
140 | static inline void queued_write_unlock(struct qrwlock *lock) | 163 | static inline void queued_write_unlock(struct qrwlock *lock) |
141 | { | 164 | { |
142 | smp_store_release((u8 *)&lock->cnts, 0); | 165 | smp_store_release(__qrwlock_write_byte(lock), 0); |
143 | } | 166 | } |
144 | 167 | ||
145 | /* | 168 | /* |