Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 2.6] missing _raw_write_trylock
@ 2004-03-16 15:09 Jun Sun
  2004-03-16 15:11 ` Steven J. Hill
  0 siblings, 1 reply; 5+ messages in thread
From: Jun Sun @ 2004-03-16 15:09 UTC (permalink / raw)
  To: linux-mips; +Cc: jsun

[-- Attachment #1: Type: text/plain, Size: 102 bytes --]

Please help me reviewing the code, because inline assembly bug is
always tricky and miserable.  

Jun

[-- Attachment #2: junk --]
[-- Type: text/plain, Size: 752 bytes --]

diff -Nru linux/include/asm-mips/spinlock.h.orig linux/include/asm-mips/spinlock.h
--- linux/include/asm-mips/spinlock.h.orig	2004-01-05 10:48:38.000000000 -0800
+++ linux/include/asm-mips/spinlock.h	2004-03-15 18:50:30.000000000 -0800
@@ -167,4 +167,28 @@
 	: "memory");
 }
 
+static inline int _raw_write_trylock(rwlock_t *rw)
+{
+	unsigned int tmp;
+	int ret;
+
+	__asm__ __volatile__(
+	".set\tnoreorder\t\t\t# _raw_write_trylock\n"
+	"li\t%2, 0\n\t"
+	"1:\tll\t%1, %3\n\t"
+	"bnez\t%1, 2f\n\t"
+	"lui\t%1, 0x8000\n\t"
+	"sc\t%1, %0\n\t"
+	"beqz\t%1, 1b\n\t"
+	"sync\n\t"
+	"li\t%2, 1\n\t"
+	".set\treorder\n"
+	"2:"
+	: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
+	: "m" (rw->lock)
+	: "memory");
+
+	return ret;
+}
+
 #endif /* _ASM_SPINLOCK_H */

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

end of thread, other threads:[~2004-03-16 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-16 15:09 [PATCH 2.6] missing _raw_write_trylock Jun Sun
2004-03-16 15:11 ` Steven J. Hill
2004-03-16 17:50   ` Jun Sun
2004-03-16 19:08     ` Christoph Hellwig
2004-03-16 19:14       ` Christopher G. Stach II

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