Commit ab7fa97e authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

[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: default avatarJames Bottomley <jejb@parisc-linux.org>
parent 2312702e
......@@ -218,6 +218,40 @@ void _dbg_write_lock(rwlock_t *rw, const char *bfile, int bline)
}
}
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
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment