2008-03-01 03:45:59 +03:00
|
|
|
#include <sys/rwlock.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-04-21 21:29:47 +04:00
|
|
|
#ifdef DEBUG_SUBSYSTEM
|
|
|
|
#undef DEBUG_SUBSYSTEM
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEBUG_SUBSYSTEM S_RWLOCK
|
|
|
|
|
2008-02-26 23:36:04 +03:00
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_read_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
2008-04-21 21:29:47 +04:00
|
|
|
ENTRY;
|
|
|
|
ASSERT(rwlp->rw_magic == RW_MAGIC);
|
|
|
|
RETURN(__rw_lock_held(rwlp) && rwlp->rw_owner == NULL);
|
2008-02-26 23:36:04 +03:00
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_read_held);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_write_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
2008-04-21 21:29:47 +04:00
|
|
|
ENTRY;
|
|
|
|
ASSERT(rwlp->rw_magic == RW_MAGIC);
|
|
|
|
RETURN(rwlp->rw_owner == current);
|
2008-02-26 23:36:04 +03:00
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_write_held);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
int
|
2008-03-07 02:42:37 +03:00
|
|
|
__rw_lock_held(krwlock_t *rwlp)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
2008-04-08 03:54:34 +04:00
|
|
|
int rc = 0;
|
2008-04-21 21:29:47 +04:00
|
|
|
ENTRY;
|
2008-04-08 03:54:34 +04:00
|
|
|
|
2008-04-21 21:29:47 +04:00
|
|
|
ASSERT(rwlp->rw_magic == RW_MAGIC);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-04-08 03:54:34 +04:00
|
|
|
spin_lock_irq(&(rwlp->rw_sem.wait_lock));
|
2008-03-07 02:42:37 +03:00
|
|
|
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
|
|
|
if (rwlp->rw_sem.activity != 0) {
|
|
|
|
#else
|
|
|
|
if (rwlp->rw_sem.count != 0) {
|
|
|
|
#endif
|
2008-04-08 03:54:34 +04:00
|
|
|
rc = 1;
|
2008-02-26 23:36:04 +03:00
|
|
|
}
|
|
|
|
|
2008-04-08 03:54:34 +04:00
|
|
|
spin_unlock_irq(&(rwlp->rw_sem.wait_lock));
|
|
|
|
|
2008-04-21 21:29:47 +04:00
|
|
|
RETURN(rc);
|
2008-02-26 23:36:04 +03:00
|
|
|
}
|
2008-03-07 02:42:37 +03:00
|
|
|
EXPORT_SYMBOL(__rw_lock_held);
|