public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] m32r: Revise __raw_read_trylock()
@ 2006-09-22  6:29 Hirokazu Takata
  2006-09-22  7:48 ` Paul Mundt
  2006-09-24  6:20 ` Matthew Wilcox
  0 siblings, 2 replies; 8+ messages in thread
From: Hirokazu Takata @ 2006-09-22  6:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Matthew Wilcox, takata

Hi,

Matthew Wilcox pointed out that generic__raw_read_trylock() is
unfit for use.

Here is a patch to fix __raw_read_trylock() for m32r.
It is taken from the i386 implementation.

Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Cc: Matthew Wilcox <matthew@wil.cx>
---
 include/asm-m32r/spinlock.h |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h
index f94c1a6..78205f0 100644
--- a/include/asm-m32r/spinlock.h
+++ b/include/asm-m32r/spinlock.h
@@ -298,7 +298,15 @@ #endif	/* CONFIG_CHIP_M32700_TS1 */
 	);
 }
 
-#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;
+	atomic_dec(count);
+	if (atomic_read(count) >= 0)
+		return 1;
+	atomic_inc(count);
+	return 0;
+}
 
 static inline int __raw_write_trylock(raw_rwlock_t *lock)
 {
-- 
Hirokazu Takata <takata@linux-m32r.org>
Linux/M32R Project:  http://www.linux-m32r.org/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-09-26 22:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-22  6:29 [PATCH] m32r: Revise __raw_read_trylock() Hirokazu Takata
2006-09-22  7:48 ` Paul Mundt
2006-09-22 11:27   ` Matthew Wilcox
2006-09-25  6:09     ` Paul Mundt
2006-09-24  6:20 ` Matthew Wilcox
2006-09-25  7:47   ` Hirokazu Takata
2006-09-26 21:33     ` Andrew Morton
2006-09-26 22:29       ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox