Commit 78474889 authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] WAITQUEUE_DEBUG cleanup

While trying out compiling of reiser4 on sparc64, ppc64, alpha, and ia64, I
discovered that WAITQUEUE_DEBUG is nowhere defined in 2.6.x, and various
compiler versions spew copious warnings at #if on it.  Convert
__SEMAPHORE_INITIALIZER() to C99 initializers while in the area.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ce183739
...@@ -18,21 +18,13 @@ ...@@ -18,21 +18,13 @@
struct semaphore { struct semaphore {
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) , (long)&(name).__magic { \
#else .count = ATOMIC_INIT(n), \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -53,9 +45,6 @@ static inline void sema_init(struct semaphore *sem, int val) ...@@ -53,9 +45,6 @@ static inline void sema_init(struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -142,7 +131,7 @@ static inline void __up(struct semaphore *sem) ...@@ -142,7 +131,7 @@ static inline void __up(struct semaphore *sem)
__up_wakeup(sem); __up_wakeup(sem);
} }
#if !defined(WAITQUEUE_DEBUG) && !defined(CONFIG_DEBUG_SEMAPHORE) #if !defined(CONFIG_DEBUG_SEMAPHORE)
extern inline void down(struct semaphore *sem) extern inline void down(struct semaphore *sem)
{ {
__down(sem); __down(sem);
......
...@@ -16,21 +16,12 @@ struct semaphore { ...@@ -16,21 +16,12 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INIT(name, cnt) \
# define __SEM_DEBUG_INIT(name) .__magic = (long)&(name).__magic { \
#else
# define __SEM_DEBUG_INIT(name)
#endif
#define __SEMAPHORE_INIT(name,cnt) { \
.count = ATOMIC_INIT(cnt), \ .count = ATOMIC_INIT(cnt), \
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \ .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
__SEM_DEBUG_INIT(name) \
} }
#define __MUTEX_INITIALIZER(name) __SEMAPHORE_INIT(name,1) #define __MUTEX_INITIALIZER(name) __SEMAPHORE_INIT(name,1)
...@@ -46,9 +37,6 @@ static inline void sema_init(struct semaphore *sem, int val) ...@@ -46,9 +37,6 @@ static inline void sema_init(struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX(struct semaphore *sem) static inline void init_MUTEX(struct semaphore *sem)
...@@ -85,9 +73,6 @@ extern void __up(struct semaphore * sem); ...@@ -85,9 +73,6 @@ extern void __up(struct semaphore * sem);
*/ */
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__down_op(sem, __down_failed); __down_op(sem, __down_failed);
} }
...@@ -98,19 +83,12 @@ static inline void down(struct semaphore * sem) ...@@ -98,19 +83,12 @@ static inline void down(struct semaphore * sem)
*/ */
static inline int down_interruptible (struct semaphore * sem) static inline int down_interruptible (struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
return __down_op_ret(sem, __down_interruptible_failed); return __down_op_ret(sem, __down_interruptible_failed);
} }
static inline int down_trylock(struct semaphore *sem) static inline int down_trylock(struct semaphore *sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
return __down_op_ret(sem, __down_trylock_failed); return __down_op_ret(sem, __down_trylock_failed);
} }
...@@ -122,10 +100,6 @@ static inline int down_trylock(struct semaphore *sem) ...@@ -122,10 +100,6 @@ static inline int down_trylock(struct semaphore *sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__up_op(sem, __up_wakeup); __up_op(sem, __up_wakeup);
} }
......
...@@ -16,22 +16,14 @@ struct semaphore { ...@@ -16,22 +16,14 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INIT(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
#endif }
#define __SEMAPHORE_INIT(name,count) \
{ ATOMIC_INIT(count), 0, \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INIT(name,1) __SEMAPHORE_INIT(name,1)
...@@ -47,9 +39,6 @@ static inline void sema_init(struct semaphore *sem, int val) ...@@ -47,9 +39,6 @@ static inline void sema_init(struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#if WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX(struct semaphore *sem) static inline void init_MUTEX(struct semaphore *sem)
...@@ -81,9 +70,6 @@ extern void __up(struct semaphore * sem); ...@@ -81,9 +70,6 @@ extern void __up(struct semaphore * sem);
*/ */
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__down_op(sem, __down_failed); __down_op(sem, __down_failed);
} }
...@@ -94,19 +80,12 @@ static inline void down(struct semaphore * sem) ...@@ -94,19 +80,12 @@ static inline void down(struct semaphore * sem)
*/ */
static inline int down_interruptible (struct semaphore * sem) static inline int down_interruptible (struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
return __down_op_ret(sem, __down_interruptible_failed); return __down_op_ret(sem, __down_interruptible_failed);
} }
static inline int down_trylock(struct semaphore *sem) static inline int down_trylock(struct semaphore *sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
return __down_op_ret(sem, __down_trylock_failed); return __down_op_ret(sem, __down_trylock_failed);
} }
...@@ -118,10 +97,6 @@ static inline int down_trylock(struct semaphore *sem) ...@@ -118,10 +97,6 @@ static inline int down_trylock(struct semaphore *sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__up_op(sem, __up_wakeup); __up_op(sem, __up_wakeup);
} }
......
...@@ -24,21 +24,14 @@ struct semaphore { ...@@ -24,21 +24,14 @@ struct semaphore {
atomic_t count; atomic_t count;
atomic_t waking; atomic_t waking;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) , (long)&(name).__magic { \
#else .count = ATOMIC_INIT(n), \
# define __SEM_DEBUG_INIT(name) .waking = ATOMIC_INIT(0), \
#endif .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
}
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), ATOMIC_INIT(0), \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -76,9 +69,6 @@ extern inline void down(struct semaphore * sem) ...@@ -76,9 +69,6 @@ extern inline void down(struct semaphore * sem)
unsigned long flags; unsigned long flags;
int failed; int failed;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
/* atomically decrement the semaphores count, and if its negative, we wait */ /* atomically decrement the semaphores count, and if its negative, we wait */
...@@ -102,9 +92,6 @@ extern inline int down_interruptible(struct semaphore * sem) ...@@ -102,9 +92,6 @@ extern inline int down_interruptible(struct semaphore * sem)
unsigned long flags; unsigned long flags;
int failed; int failed;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
/* atomically decrement the semaphores count, and if its negative, we wait */ /* atomically decrement the semaphores count, and if its negative, we wait */
...@@ -122,10 +109,6 @@ extern inline int down_trylock(struct semaphore * sem) ...@@ -122,10 +109,6 @@ extern inline int down_trylock(struct semaphore * sem)
unsigned long flags; unsigned long flags;
int failed; int failed;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
local_save_flags(flags); local_save_flags(flags);
local_irq_disable(); local_irq_disable();
failed = --(sem->count.counter) < 0; failed = --(sem->count.counter) < 0;
...@@ -146,10 +129,6 @@ extern inline void up(struct semaphore * sem) ...@@ -146,10 +129,6 @@ extern inline void up(struct semaphore * sem)
unsigned long flags; unsigned long flags;
int wakeup; int wakeup;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
/* atomically increment the semaphores count, and if it was negative, we wake people */ /* atomically increment the semaphores count, and if it was negative, we wake people */
local_save_flags(flags); local_save_flags(flags);
local_irq_disable(); local_irq_disable();
......
...@@ -26,21 +26,14 @@ struct semaphore { ...@@ -26,21 +26,14 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -87,9 +80,6 @@ static inline void down(struct semaphore * sem) ...@@ -87,9 +80,6 @@ static inline void down(struct semaphore * sem)
{ {
register atomic_t *count asm("er0"); register atomic_t *count asm("er0");
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
count = &(sem->count); count = &(sem->count);
...@@ -116,9 +106,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -116,9 +106,6 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
register atomic_t *count asm("er0"); register atomic_t *count asm("er0");
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
count = &(sem->count); count = &(sem->count);
...@@ -147,10 +134,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -147,10 +134,6 @@ static inline int down_trylock(struct semaphore * sem)
{ {
register atomic_t *count asm("er0"); register atomic_t *count asm("er0");
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
count = &(sem->count); count = &(sem->count);
__asm__ __volatile__( __asm__ __volatile__(
"stc ccr,r3l\n\t" "stc ccr,r3l\n\t"
...@@ -187,10 +170,6 @@ static inline void up(struct semaphore * sem) ...@@ -187,10 +170,6 @@ static inline void up(struct semaphore * sem)
{ {
register atomic_t *count asm("er0"); register atomic_t *count asm("er0");
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
count = &(sem->count); count = &(sem->count);
__asm__ __volatile__( __asm__ __volatile__(
"stc ccr,r3l\n\t" "stc ccr,r3l\n\t"
......
...@@ -45,21 +45,15 @@ struct semaphore { ...@@ -45,21 +45,15 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG
# define __SEM_DEBUG_INIT(name) \
, (int)&(name).__magic
#else
# define __SEM_DEBUG_INIT(name)
#endif
#define __SEMAPHORE_INITIALIZER(name,count) \ #define __SEMAPHORE_INITIALIZER(name, n) \
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ { \
__SEM_DEBUG_INIT(name) } .count = ATOMIC_INIT(n), \
.sleepers = 0, \
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
}
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -81,9 +75,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -81,9 +75,6 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (int)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -113,9 +104,6 @@ asmlinkage void __up(struct semaphore * sem); ...@@ -113,9 +104,6 @@ asmlinkage void __up(struct semaphore * sem);
*/ */
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"# atomic down operation\n\t" "# atomic down operation\n\t"
...@@ -139,9 +127,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -139,9 +127,6 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
int result; int result;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"# atomic interruptible down operation\n\t" "# atomic interruptible down operation\n\t"
...@@ -167,10 +152,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -167,10 +152,6 @@ static inline int down_trylock(struct semaphore * sem)
{ {
int result; int result;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"# atomic interruptible down operation\n\t" "# atomic interruptible down operation\n\t"
LOCK "decl %1\n\t" /* --sem->count */ LOCK "decl %1\n\t" /* --sem->count */
...@@ -195,9 +176,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -195,9 +176,6 @@ static inline int down_trylock(struct semaphore * sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"# atomic up operation\n\t" "# atomic up operation\n\t"
LOCK "incl %0\n\t" /* ++sem->count */ LOCK "incl %0\n\t" /* ++sem->count */
......
...@@ -15,21 +15,13 @@ struct semaphore { ...@@ -15,21 +15,13 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic; /* initialized by __SEM_DEBUG_INIT() */
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) , (long) &(name).__magic { \
#else .count = ATOMIC_INIT(n), \
# define __SEM_DEBUG_INIT(name) .sleepers = 0, \
#endif .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#define __SEMAPHORE_INITIALIZER(name,count) \
{ \
ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) \
} }
#define __MUTEX_INITIALIZER(name) __SEMAPHORE_INITIALIZER(name,1) #define __MUTEX_INITIALIZER(name) __SEMAPHORE_INITIALIZER(name,1)
...@@ -70,9 +62,6 @@ extern void __up (struct semaphore * sem); ...@@ -70,9 +62,6 @@ extern void __up (struct semaphore * sem);
static inline void static inline void
down (struct semaphore *sem) down (struct semaphore *sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
__down(sem); __down(sem);
...@@ -87,9 +76,6 @@ down_interruptible (struct semaphore * sem) ...@@ -87,9 +76,6 @@ down_interruptible (struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
ret = __down_interruptible(sem); ret = __down_interruptible(sem);
...@@ -101,9 +87,6 @@ down_trylock (struct semaphore *sem) ...@@ -101,9 +87,6 @@ down_trylock (struct semaphore *sem)
{ {
int ret = 0; int ret = 0;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
ret = __down_trylock(sem); ret = __down_trylock(sem);
return ret; return ret;
...@@ -112,9 +95,6 @@ down_trylock (struct semaphore *sem) ...@@ -112,9 +95,6 @@ down_trylock (struct semaphore *sem)
static inline void static inline void
up (struct semaphore * sem) up (struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_inc_return(&sem->count) <= 0) if (atomic_inc_return(&sem->count) <= 0)
__up(sem); __up(sem);
} }
......
...@@ -27,21 +27,14 @@ struct semaphore { ...@@ -27,21 +27,14 @@ struct semaphore {
atomic_t count; atomic_t count;
atomic_t waking; atomic_t waking;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .waking = ATOMIC_INIT(0), \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), ATOMIC_INIT(0), __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -86,9 +79,6 @@ static inline void down(struct semaphore *sem) ...@@ -86,9 +79,6 @@ static inline void down(struct semaphore *sem)
{ {
register struct semaphore *sem1 __asm__ ("%a1") = sem; register struct semaphore *sem1 __asm__ ("%a1") = sem;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"| atomic down operation\n\t" "| atomic down operation\n\t"
...@@ -109,9 +99,6 @@ static inline int down_interruptible(struct semaphore *sem) ...@@ -109,9 +99,6 @@ static inline int down_interruptible(struct semaphore *sem)
register struct semaphore *sem1 __asm__ ("%a1") = sem; register struct semaphore *sem1 __asm__ ("%a1") = sem;
register int result __asm__ ("%d0"); register int result __asm__ ("%d0");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"| atomic interruptible down operation\n\t" "| atomic interruptible down operation\n\t"
...@@ -134,10 +121,6 @@ static inline int down_trylock(struct semaphore *sem) ...@@ -134,10 +121,6 @@ static inline int down_trylock(struct semaphore *sem)
register struct semaphore *sem1 __asm__ ("%a1") = sem; register struct semaphore *sem1 __asm__ ("%a1") = sem;
register int result __asm__ ("%d0"); register int result __asm__ ("%d0");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"| atomic down trylock operation\n\t" "| atomic down trylock operation\n\t"
"subql #1,%1@\n\t" "subql #1,%1@\n\t"
...@@ -164,10 +147,6 @@ static inline void up(struct semaphore *sem) ...@@ -164,10 +147,6 @@ static inline void up(struct semaphore *sem)
{ {
register struct semaphore *sem1 __asm__ ("%a1") = sem; register struct semaphore *sem1 __asm__ ("%a1") = sem;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"| atomic up operation\n\t" "| atomic up operation\n\t"
"addql #1,%0@\n\t" "addql #1,%0@\n\t"
......
...@@ -26,21 +26,14 @@ struct semaphore { ...@@ -26,21 +26,14 @@ struct semaphore {
atomic_t count; atomic_t count;
atomic_t waking; atomic_t waking;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .waking = ATOMIC_INIT(0), \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), ATOMIC_INIT(0), __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -85,9 +78,6 @@ extern spinlock_t semaphore_wake_lock; ...@@ -85,9 +78,6 @@ extern spinlock_t semaphore_wake_lock;
*/ */
extern inline void down(struct semaphore * sem) extern inline void down(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"| atomic down operation\n\t" "| atomic down operation\n\t"
...@@ -105,9 +95,6 @@ extern inline int down_interruptible(struct semaphore * sem) ...@@ -105,9 +95,6 @@ extern inline int down_interruptible(struct semaphore * sem)
{ {
int ret; int ret;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
"| atomic down operation\n\t" "| atomic down operation\n\t"
...@@ -128,10 +115,6 @@ extern inline int down_trylock(struct semaphore * sem) ...@@ -128,10 +115,6 @@ extern inline int down_trylock(struct semaphore * sem)
register struct semaphore *sem1 __asm__ ("%a1") = sem; register struct semaphore *sem1 __asm__ ("%a1") = sem;
register int result __asm__ ("%d0"); register int result __asm__ ("%d0");
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"| atomic down trylock operation\n\t" "| atomic down trylock operation\n\t"
"subql #1,%1@\n\t" "subql #1,%1@\n\t"
...@@ -157,10 +140,6 @@ extern inline int down_trylock(struct semaphore * sem) ...@@ -157,10 +140,6 @@ extern inline int down_trylock(struct semaphore * sem)
*/ */
extern inline void up(struct semaphore * sem) extern inline void up(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"| atomic up operation\n\t" "| atomic up operation\n\t"
"movel %0, %%a1\n\t" "movel %0, %%a1\n\t"
......
...@@ -37,22 +37,13 @@ struct semaphore { ...@@ -37,22 +37,13 @@ struct semaphore {
*/ */
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
# define __SEM_DEBUG_INIT(name) }
#endif
#define __SEMAPHORE_INITIALIZER(name, count) \
{ ATOMIC_INIT(count), \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name, 1) __SEMAPHORE_INITIALIZER(name, 1)
...@@ -67,9 +58,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -67,9 +58,6 @@ static inline void sema_init (struct semaphore *sem, int val)
{ {
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -88,9 +76,6 @@ extern void __up(struct semaphore * sem); ...@@ -88,9 +76,6 @@ extern void __up(struct semaphore * sem);
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
/* /*
...@@ -104,9 +89,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -104,9 +89,6 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (unlikely(atomic_dec_return(&sem->count) < 0)) if (unlikely(atomic_dec_return(&sem->count) < 0))
...@@ -116,19 +98,11 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -116,19 +98,11 @@ static inline int down_interruptible(struct semaphore * sem)
static inline int down_trylock(struct semaphore * sem) static inline int down_trylock(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
return atomic_dec_if_positive(&sem->count) < 0; return atomic_dec_if_positive(&sem->count) < 0;
} }
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (unlikely(atomic_inc_return(&sem->count) <= 0)) if (unlikely(atomic_inc_return(&sem->count) <= 0))
__up(sem); __up(sem);
} }
......
...@@ -40,21 +40,14 @@ struct semaphore { ...@@ -40,21 +40,14 @@ struct semaphore {
spinlock_t sentry; spinlock_t sentry;
int count; int count;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#if WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .sentry = SPIN_LOCK_UNLOCKED, \
#else .count = n, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ SPIN_LOCK_UNLOCKED, count, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -95,9 +88,6 @@ asmlinkage void __up(struct semaphore * sem); ...@@ -95,9 +88,6 @@ asmlinkage void __up(struct semaphore * sem);
extern __inline__ void down(struct semaphore * sem) extern __inline__ void down(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
spin_lock_irq(&sem->sentry); spin_lock_irq(&sem->sentry);
if (sem->count > 0) { if (sem->count > 0) {
...@@ -111,9 +101,6 @@ extern __inline__ void down(struct semaphore * sem) ...@@ -111,9 +101,6 @@ extern __inline__ void down(struct semaphore * sem)
extern __inline__ int down_interruptible(struct semaphore * sem) extern __inline__ int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
spin_lock_irq(&sem->sentry); spin_lock_irq(&sem->sentry);
if (sem->count > 0) { if (sem->count > 0) {
...@@ -132,9 +119,6 @@ extern __inline__ int down_interruptible(struct semaphore * sem) ...@@ -132,9 +119,6 @@ extern __inline__ int down_interruptible(struct semaphore * sem)
extern __inline__ int down_trylock(struct semaphore * sem) extern __inline__ int down_trylock(struct semaphore * sem)
{ {
int flags, count; int flags, count;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
spin_lock_irqsave(&sem->sentry, flags); spin_lock_irqsave(&sem->sentry, flags);
count = sem->count - 1; count = sem->count - 1;
...@@ -151,9 +135,6 @@ extern __inline__ int down_trylock(struct semaphore * sem) ...@@ -151,9 +135,6 @@ extern __inline__ int down_trylock(struct semaphore * sem)
extern __inline__ void up(struct semaphore * sem) extern __inline__ void up(struct semaphore * sem)
{ {
int flags; int flags;
#if WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
spin_lock_irqsave(&sem->sentry, flags); spin_lock_irqsave(&sem->sentry, flags);
if (sem->count < 0) { if (sem->count < 0) {
__up(sem); __up(sem);
......
...@@ -29,22 +29,13 @@ struct semaphore { ...@@ -29,22 +29,13 @@ struct semaphore {
*/ */
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
# define __SEM_DEBUG_INIT(name) }
#endif
#define __SEMAPHORE_INITIALIZER(name, count) \
{ ATOMIC_INIT(count), \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name, 1) __SEMAPHORE_INITIALIZER(name, 1)
...@@ -59,9 +50,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -59,9 +50,6 @@ static inline void sema_init (struct semaphore *sem, int val)
{ {
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -80,9 +68,6 @@ extern void __up(struct semaphore * sem); ...@@ -80,9 +68,6 @@ extern void __up(struct semaphore * sem);
extern inline void down(struct semaphore * sem) extern inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
/* /*
...@@ -97,9 +82,6 @@ extern inline int down_interruptible(struct semaphore * sem) ...@@ -97,9 +82,6 @@ extern inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
...@@ -112,10 +94,6 @@ extern inline int down_trylock(struct semaphore * sem) ...@@ -112,10 +94,6 @@ extern inline int down_trylock(struct semaphore * sem)
{ {
int ret; int ret;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
ret = atomic_dec_if_positive(&sem->count) < 0; ret = atomic_dec_if_positive(&sem->count) < 0;
smp_wmb(); smp_wmb();
return ret; return ret;
...@@ -123,10 +101,6 @@ extern inline int down_trylock(struct semaphore * sem) ...@@ -123,10 +101,6 @@ extern inline int down_trylock(struct semaphore * sem)
extern inline void up(struct semaphore * sem) extern inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
smp_wmb(); smp_wmb();
if (atomic_inc_return(&sem->count) <= 0) if (atomic_inc_return(&sem->count) <= 0)
__up(sem); __up(sem);
......
...@@ -23,22 +23,13 @@ struct semaphore { ...@@ -23,22 +23,13 @@ struct semaphore {
*/ */
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC_INIT(n), \
#else .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
# define __SEM_DEBUG_INIT(name) }
#endif
#define __SEMAPHORE_INITIALIZER(name, count) \
{ ATOMIC_INIT(count), \
__WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name, 1) __SEMAPHORE_INITIALIZER(name, 1)
...@@ -53,9 +44,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -53,9 +44,6 @@ static inline void sema_init (struct semaphore *sem, int val)
{ {
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -74,9 +62,6 @@ extern void __up(struct semaphore * sem); ...@@ -74,9 +62,6 @@ extern void __up(struct semaphore * sem);
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
/* /*
...@@ -90,9 +75,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -90,9 +75,6 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (unlikely(atomic_dec_return(&sem->count) < 0)) if (unlikely(atomic_dec_return(&sem->count) < 0))
...@@ -102,19 +84,11 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -102,19 +84,11 @@ static inline int down_interruptible(struct semaphore * sem)
static inline int down_trylock(struct semaphore * sem) static inline int down_trylock(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
return atomic_dec_if_positive(&sem->count) < 0; return atomic_dec_if_positive(&sem->count) < 0;
} }
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (unlikely(atomic_inc_return(&sem->count) <= 0)) if (unlikely(atomic_inc_return(&sem->count) <= 0))
__up(sem); __up(sem);
} }
......
...@@ -24,21 +24,14 @@ struct semaphore { ...@@ -24,21 +24,14 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (int)&(name).__magic .count = ATOMIC_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -60,9 +53,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -60,9 +53,6 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (int)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -91,10 +81,6 @@ extern spinlock_t semaphore_wake_lock; ...@@ -91,10 +81,6 @@ extern spinlock_t semaphore_wake_lock;
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
__down(sem); __down(sem);
...@@ -103,9 +89,6 @@ static inline void down(struct semaphore * sem) ...@@ -103,9 +89,6 @@ static inline void down(struct semaphore * sem)
static inline int down_interruptible(struct semaphore * sem) static inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
...@@ -116,9 +99,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -116,9 +99,6 @@ static inline int down_interruptible(struct semaphore * sem)
static inline int down_trylock(struct semaphore * sem) static inline int down_trylock(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
ret = __down_trylock(sem); ret = __down_trylock(sem);
...@@ -131,9 +111,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -131,9 +111,6 @@ static inline int down_trylock(struct semaphore * sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_inc_return(&sem->count) <= 0) if (atomic_inc_return(&sem->count) <= 0)
__up(sem); __up(sem);
} }
......
...@@ -31,21 +31,14 @@ struct semaphore { ...@@ -31,21 +31,14 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (int)&(name).__magic .count = ATOMIC_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -67,9 +60,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -67,9 +60,6 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (int)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -98,10 +88,6 @@ extern spinlock_t semaphore_wake_lock; ...@@ -98,10 +88,6 @@ extern spinlock_t semaphore_wake_lock;
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
__down(sem); __down(sem);
} }
...@@ -109,9 +95,6 @@ static inline void down(struct semaphore * sem) ...@@ -109,9 +95,6 @@ static inline void down(struct semaphore * sem)
static inline int down_interruptible(struct semaphore * sem) static inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
ret = __down_interruptible(sem); ret = __down_interruptible(sem);
...@@ -121,9 +104,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -121,9 +104,6 @@ static inline int down_interruptible(struct semaphore * sem)
static inline int down_trylock(struct semaphore * sem) static inline int down_trylock(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_dec_return(&sem->count) < 0) if (atomic_dec_return(&sem->count) < 0)
ret = __down_trylock(sem); ret = __down_trylock(sem);
...@@ -136,9 +116,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -136,9 +116,6 @@ static inline int down_trylock(struct semaphore * sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
if (atomic_inc_return(&sem->count) <= 0) if (atomic_inc_return(&sem->count) <= 0)
__up(sem); __up(sem);
} }
......
...@@ -13,21 +13,14 @@ struct semaphore { ...@@ -13,21 +13,14 @@ struct semaphore {
atomic24_t count; atomic24_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (long)&(name).__magic .count = ATOMIC24_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC24_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -43,9 +36,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -43,9 +36,6 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic24_set(&sem->count, val); atomic24_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -68,9 +58,6 @@ static inline void down(struct semaphore * sem) ...@@ -68,9 +58,6 @@ static inline void down(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
ptr = &(sem->count.counter); ptr = &(sem->count.counter);
...@@ -105,9 +92,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -105,9 +92,6 @@ static inline int down_interruptible(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
ptr = &(sem->count.counter); ptr = &(sem->count.counter);
...@@ -145,10 +129,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -145,10 +129,6 @@ static inline int down_trylock(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
ptr = &(sem->count.counter); ptr = &(sem->count.counter);
increment = 1; increment = 1;
...@@ -184,10 +164,6 @@ static inline void up(struct semaphore * sem) ...@@ -184,10 +164,6 @@ static inline void up(struct semaphore * sem)
register volatile int *ptr asm("g1"); register volatile int *ptr asm("g1");
register int increment asm("g2"); register int increment asm("g2");
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
ptr = &(sem->count.counter); ptr = &(sem->count.counter);
increment = 1; increment = 1;
......
...@@ -47,21 +47,14 @@ struct semaphore { ...@@ -47,21 +47,14 @@ struct semaphore {
atomic_t count; atomic_t count;
int sleepers; int sleepers;
wait_queue_head_t wait; wait_queue_head_t wait;
#ifdef WAITQUEUE_DEBUG
long __magic;
#endif
}; };
#ifdef WAITQUEUE_DEBUG #define __SEMAPHORE_INITIALIZER(name, n) \
# define __SEM_DEBUG_INIT(name) \ { \
, (int)&(name).__magic .count = ATOMIC_INIT(n), \
#else .sleepers = 0, \
# define __SEM_DEBUG_INIT(name) .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
#endif }
#define __SEMAPHORE_INITIALIZER(name,count) \
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
__SEM_DEBUG_INIT(name) }
#define __MUTEX_INITIALIZER(name) \ #define __MUTEX_INITIALIZER(name) \
__SEMAPHORE_INITIALIZER(name,1) __SEMAPHORE_INITIALIZER(name,1)
...@@ -83,9 +76,6 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -83,9 +76,6 @@ static inline void sema_init (struct semaphore *sem, int val)
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
sem->sleepers = 0; sem->sleepers = 0;
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#ifdef WAITQUEUE_DEBUG
sem->__magic = (int)&sem->__magic;
#endif
} }
static inline void init_MUTEX (struct semaphore *sem) static inline void init_MUTEX (struct semaphore *sem)
...@@ -115,9 +105,6 @@ asmlinkage void __up(struct semaphore * sem); ...@@ -115,9 +105,6 @@ asmlinkage void __up(struct semaphore * sem);
*/ */
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
...@@ -142,9 +129,6 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -142,9 +129,6 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
int result; int result;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
might_sleep(); might_sleep();
__asm__ __volatile__( __asm__ __volatile__(
...@@ -171,10 +155,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -171,10 +155,6 @@ static inline int down_trylock(struct semaphore * sem)
{ {
int result; int result;
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"# atomic interruptible down operation\n\t" "# atomic interruptible down operation\n\t"
LOCK "decl %1\n\t" /* --sem->count */ LOCK "decl %1\n\t" /* --sem->count */
...@@ -199,9 +179,6 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -199,9 +179,6 @@ static inline int down_trylock(struct semaphore * sem)
*/ */
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic);
#endif
__asm__ __volatile__( __asm__ __volatile__(
"# atomic up operation\n\t" "# atomic up operation\n\t"
LOCK "incl %0\n\t" /* ++sem->count */ LOCK "incl %0\n\t" /* ++sem->count */
......
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