summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2004-11-01 01:03:25 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-01 01:03:25 -0800
commitab7fa97e25d5171ede4229eae59cbb7f906e6ba3 (patch)
tree603d3b994ecf5741f7f18e0a429c6fbb1110bad6
parent2312702e240707ba7484c552bf3f47ad789e5e78 (diff)
[PATCH] parisc: _raw_write_trylock
Need a _raw_write_trylock() for the out of line spinlock code to compile ... nothing in the kernel actually uses this, of course ... Committed-by: James Bottomley <jejb@parisc-linux.org>
-rw-r--r--arch/parisc/lib/debuglocks.c34
-rw-r--r--include/asm-parisc/spinlock.h20
2 files changed, 54 insertions, 0 deletions
diff --git a/arch/parisc/lib/debuglocks.c b/arch/parisc/lib/debuglocks.c
index 908b3e6dbfc6..5ac3eb047276 100644
--- a/arch/parisc/lib/debuglocks.c
+++ b/arch/parisc/lib/debuglocks.c
@@ -218,6 +218,40 @@ retry:
}
}
+int _dbg_write_trylock(rwlock_t *rw, const char *bfile, int bline)
+{
+#if 0
+ void *inline_pc = __builtin_return_address(0);
+ int cpu = smp_processor_id();
+#endif
+
+ if(unlikely(in_interrupt())) { /* acquiring write lock in interrupt context, bad idea */
+ pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+ BUG();
+ }
+
+ /* Note: if interrupts are disabled (which is most likely), the printk
+ will never show on the console. We might need a polling method to flush
+ the dmesg buffer anyhow. */
+
+ _raw_spin_lock(&rw->lock);
+
+ if(rw->counter != 0) {
+ /* this basically never happens */
+ _raw_spin_unlock(&rw->lock);
+
+
+ return 0;
+ }
+
+ /* got it. now leave without unlocking */
+ rw->counter = -1; /* remember we are locked */
+#if 0
+ pdc_printf("%s:%d: try write_lock grabbed in %s at %p(%d)\n",
+ bfile, bline, current->comm, inline_pc, cpu);
+#endif
+}
+
void _dbg_read_lock(rwlock_t * rw, const char *bfile, int bline)
{
#if 0
diff --git a/include/asm-parisc/spinlock.h b/include/asm-parisc/spinlock.h
index ef5e00eac7c0..8a65f6c766e7 100644
--- a/include/asm-parisc/spinlock.h
+++ b/include/asm-parisc/spinlock.h
@@ -222,6 +222,26 @@ static __inline__ void _raw_write_unlock(rwlock_t *rw)
_raw_spin_unlock(&rw->lock);
}
+#ifdef CONFIG_DEBUG_RWLOCK
+extern void _dbg_write_trylock(rwlock_t * rw, const char *bfile, int bline);
+#define _raw_write_trylock(rw) _dbg_write_trylock(rw, __FILE__, __LINE__)
+#else
+static __inline__ int _raw_write_trylock(rwlock_t *rw)
+{
+ _raw_spin_lock(&rw->lock);
+ if (rw->counter != 0) {
+ /* this basically never happens */
+ _raw_spin_unlock(&rw->lock);
+
+ return 0;
+ }
+
+ /* got it. now leave without unlocking */
+ rw->counter = -1; /* remember we are locked */
+ return 1;
+}
+#endif /* CONFIG_DEBUG_RWLOCK */
+
static __inline__ int is_read_locked(rwlock_t *rw)
{
return rw->counter > 0;