From fac99d97469e7f91102f97101bea620e5f073196 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Tue, 3 Oct 2006 14:13:09 +0900 Subject: [PATCH] sh: Fixup __raw_read_trylock(). generic__raw_read_trylock() was broken, fix up the __raw_read_trylock() implementation for something sensible. Taken from m32r, which has the same use cases. Signed-off-by: Paul Mundt --- include/asm-sh/spinlock.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/asm-sh/spinlock.h b/include/asm-sh/spinlock.h index 54458fd24981..2586eef07d57 100644 --- a/include/asm-sh/spinlock.h +++ b/include/asm-sh/spinlock.h @@ -88,7 +88,14 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) __raw_spin_unlock(&rw->lock); } -#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) +static inline int __raw_read_trylock(raw_rwlock_t *lock) +{ + atomic_t *count = (atomic_t*)lock; + if (atomic_dec_return(count) >= 0) + return 1; + atomic_inc(count); + return 0; +} static inline int __raw_write_trylock(raw_rwlock_t *rw) { -- 2.39.5