aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/spinlock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips/spinlock.h')
-rw-r--r--include/asm-mips/spinlock.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/include/asm-mips/spinlock.h b/include/asm-mips/spinlock.h
index 4d0135b11156..669b8e349ff2 100644
--- a/include/asm-mips/spinlock.h
+++ b/include/asm-mips/spinlock.h
@@ -9,17 +9,16 @@
9#ifndef _ASM_SPINLOCK_H 9#ifndef _ASM_SPINLOCK_H
10#define _ASM_SPINLOCK_H 10#define _ASM_SPINLOCK_H
11 11
12#include <linux/config.h>
13#include <asm/war.h> 12#include <asm/war.h>
14 13
15/* 14/*
16 * Your basic SMP spinlocks, allowing only a single CPU anywhere 15 * Your basic SMP spinlocks, allowing only a single CPU anywhere
17 */ 16 */
18 17
19#define __raw_spin_is_locked(x) ((x)->lock != 0) 18#define __raw_spin_is_locked(x) ((x)->lock != 0)
20#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 19#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
21#define __raw_spin_unlock_wait(x) \ 20#define __raw_spin_unlock_wait(x) \
22 do { cpu_relax(); } while ((x)->lock) 21 do { cpu_relax(); } while ((x)->lock)
23 22
24/* 23/*
25 * Simple spin lock operations. There are two variants, one clears IRQ's 24 * Simple spin lock operations. There are two variants, one clears IRQ's
@@ -119,6 +118,18 @@ static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
119 * read-locks. 118 * read-locks.
120 */ 119 */
121 120
121/*
122 * read_can_lock - would read_trylock() succeed?
123 * @lock: the rwlock in question.
124 */
125#define __raw_read_can_lock(rw) ((rw)->lock >= 0)
126
127/*
128 * write_can_lock - would write_trylock() succeed?
129 * @lock: the rwlock in question.
130 */
131#define __raw_write_can_lock(rw) (!(rw)->lock)
132
122static inline void __raw_read_lock(raw_rwlock_t *rw) 133static inline void __raw_read_lock(raw_rwlock_t *rw)
123{ 134{
124 unsigned int tmp; 135 unsigned int tmp;
@@ -197,8 +208,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
197 " lui %1, 0x8000 \n" 208 " lui %1, 0x8000 \n"
198 " sc %1, %0 \n" 209 " sc %1, %0 \n"
199 " beqzl %1, 1b \n" 210 " beqzl %1, 1b \n"
200 " nop \n" 211 " sync \n"
201 " sync \n"
202 " .set reorder \n" 212 " .set reorder \n"
203 : "=m" (rw->lock), "=&r" (tmp) 213 : "=m" (rw->lock), "=&r" (tmp)
204 : "m" (rw->lock) 214 : "m" (rw->lock)
@@ -211,8 +221,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
211 " lui %1, 0x8000 \n" 221 " lui %1, 0x8000 \n"
212 " sc %1, %0 \n" 222 " sc %1, %0 \n"
213 " beqz %1, 1b \n" 223 " beqz %1, 1b \n"
214 " nop \n" 224 " sync \n"
215 " sync \n"
216 " .set reorder \n" 225 " .set reorder \n"
217 : "=m" (rw->lock), "=&r" (tmp) 226 : "=m" (rw->lock), "=&r" (tmp)
218 : "m" (rw->lock) 227 : "m" (rw->lock)
@@ -246,8 +255,7 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
246 " lui %1, 0x8000 \n" 255 " lui %1, 0x8000 \n"
247 " sc %1, %0 \n" 256 " sc %1, %0 \n"
248 " beqzl %1, 1b \n" 257 " beqzl %1, 1b \n"
249 " nop \n" 258 " sync \n"
250 " sync \n"
251 " li %2, 1 \n" 259 " li %2, 1 \n"
252 " .set reorder \n" 260 " .set reorder \n"
253 "2: \n" 261 "2: \n"