summaryrefslogtreecommitdiffstats
path: root/include/asm-arm/spinlock.h
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-08-31 15:09:30 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-08-31 15:09:30 +0100
commit8e34703b9315688305306d26148088b0a8292563 (patch)
tree86955dfb894b441525be160e1f6814e6cfbd9a3c /include/asm-arm/spinlock.h
parent0355b3e039c621d15321fd0d5cf72d8bdb8f723d (diff)
[ARM] Fix ARM __raw_read_trylock() implementation
Matthew Wilcox pointed out that the generic implementation of this is unfit for use. Here's an ARM optimised version instead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/asm-arm/spinlock.h')
-rw-r--r--include/asm-arm/spinlock.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/asm-arm/spinlock.h b/include/asm-arm/spinlock.h
index 406ca97a8ab..e2f1d75171d 100644
--- a/include/asm-arm/spinlock.h
+++ b/include/asm-arm/spinlock.h
@@ -199,7 +199,21 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
: "cc");
}
-#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
+static inline int __raw_read_trylock(raw_rwlock_t *rw)
+{
+ unsigned long tmp tmp2 = 1;
+
+ __asm__ __volatile__(
+"1: ldrex %0, [%2]\n"
+" adds %0, %0, #1\n"
+" strexpl %1, %0, [%2]\n"
+ : "=&r" (tmp), "+r" (tmp2)
+ : "r" (&rw->lock)
+ : "cc");
+
+ smp_mb();
+ return tmp2 == 0;
+}
/* read_can_lock - would read_trylock() succeed? */
#define __raw_read_can_lock(x) ((x)->lock < 0x80000000)