[PATCH 2.6] missing _raw_write_trylock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Jun
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 */

[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux