From: Hirokazu Takata Date: Wed, 27 Sep 2006 08:50:24 +0000 (-0700) Subject: [PATCH] m32r: revise __raw_read_trylock() X-Git-Tag: v2.6.19-rc1~945 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85f651794c46e8e3faf204a767d1caa7f9f278f0;p=linux-2.6 [PATCH] m32r: revise __raw_read_trylock() Signed-off-by: Hirokazu Takata Cc: Matthew Wilcox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h index f94c1a6735..f9f90727a4 100644 --- a/include/asm-m32r/spinlock.h +++ b/include/asm-m32r/spinlock.h @@ -298,7 +298,14 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) ); } -#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 *lock) {