2008-03-01 00:45:59 +00:00
|
|
|
#include <sys/rwlock.h>
|
2008-02-26 20:36:04 +00:00
|
|
|
|
|
|
|
int
|
2008-03-06 23:42:37 +00:00
|
|
|
__rw_read_held(krwlock_t *rwlp)
|
2008-02-26 20:36:04 +00:00
|
|
|
{
|
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-03-06 23:42:37 +00:00
|
|
|
if (__rw_lock_held(rwlp) && rwlp->rw_owner == NULL) {
|
2008-02-26 20:36:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2008-02-27 19:09:51 +00:00
|
|
|
|
2008-02-26 20:36:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-03-06 23:42:37 +00:00
|
|
|
EXPORT_SYMBOL(__rw_read_held);
|
2008-02-26 20:36:04 +00:00
|
|
|
|
|
|
|
int
|
2008-03-06 23:42:37 +00:00
|
|
|
__rw_write_held(krwlock_t *rwlp)
|
2008-02-26 20:36:04 +00:00
|
|
|
{
|
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-03-06 23:42:37 +00:00
|
|
|
if (rwlp->rw_owner == current) {
|
2008-02-26 20:36:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-06 23:42:37 +00:00
|
|
|
EXPORT_SYMBOL(__rw_write_held);
|
2008-02-26 20:36:04 +00:00
|
|
|
|
|
|
|
int
|
2008-03-06 23:42:37 +00:00
|
|
|
__rw_lock_held(krwlock_t *rwlp)
|
2008-02-26 20:36:04 +00:00
|
|
|
{
|
2008-04-07 23:54:34 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2008-02-26 20:36:04 +00:00
|
|
|
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
|
|
|
|
2008-04-07 23:54:34 +00:00
|
|
|
spin_lock_irq(&(rwlp->rw_sem.wait_lock));
|
2008-03-06 23:42:37 +00:00
|
|
|
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
|
|
|
if (rwlp->rw_sem.activity != 0) {
|
|
|
|
#else
|
|
|
|
if (rwlp->rw_sem.count != 0) {
|
|
|
|
#endif
|
2008-04-07 23:54:34 +00:00
|
|
|
rc = 1;
|
2008-02-26 20:36:04 +00:00
|
|
|
}
|
|
|
|
|
2008-04-07 23:54:34 +00:00
|
|
|
spin_unlock_irq(&(rwlp->rw_sem.wait_lock));
|
|
|
|
|
|
|
|
return rc;
|
2008-02-26 20:36:04 +00:00
|
|
|
}
|
2008-03-06 23:42:37 +00:00
|
|
|
EXPORT_SYMBOL(__rw_lock_held);
|