X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Fasm-h8300%2Fsemaphore.h;h=81bae2a99192af8ed1747491f2af24929d8fd59a;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=283f0860a2af04a358a33130fe9e71aa6934c653;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/include/asm-h8300/semaphore.h b/include/asm-h8300/semaphore.h index 283f0860a..81bae2a99 100644 --- a/include/asm-h8300/semaphore.h +++ b/include/asm-h8300/semaphore.h @@ -26,24 +26,14 @@ struct semaphore { atomic_t count; int sleepers; wait_queue_head_t wait; -#if WAITQUEUE_DEBUG - long __magic; -#endif }; -#if WAITQUEUE_DEBUG -# define __SEM_DEBUG_INIT(name) \ - , (long)&(name).__magic -#else -# define __SEM_DEBUG_INIT(name) -#endif - -#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 __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .count = ATOMIC_INIT(n), \ + .sleepers = 0, \ + .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ +} #define __DECLARE_SEMAPHORE_GENERIC(name,count) \ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) @@ -87,16 +77,13 @@ static inline void down(struct semaphore * sem) { register atomic_t *count asm("er0"); -#if WAITQUEUE_DEBUG - CHECK_MAGIC(sem->__magic); -#endif might_sleep(); count = &(sem->count); __asm__ __volatile__( "stc ccr,r3l\n\t" "orc #0x80,ccr\n\t" - "mov.l %0, er1\n\t" + "mov.l %2, er1\n\t" "dec.l #1,er1\n\t" "mov.l er1,%0\n\t" "bpl 1f\n\t" @@ -107,8 +94,8 @@ static inline void down(struct semaphore * sem) "1:\n\t" "ldc r3l,ccr\n" "2:" - : "+m"(*count) - : "g"(sem) + : "=m"(*count) + : "g"(sem),"m"(*count) : "cc", "er1", "er2", "er3"); } @@ -116,16 +103,13 @@ static inline int down_interruptible(struct semaphore * sem) { register atomic_t *count asm("er0"); -#if WAITQUEUE_DEBUG - CHECK_MAGIC(sem->__magic); -#endif might_sleep(); count = &(sem->count); __asm__ __volatile__( "stc ccr,r1l\n\t" "orc #0x80,ccr\n\t" - "mov.l %1, er2\n\t" + "mov.l %3, er2\n\t" "dec.l #1,er2\n\t" "mov.l er2,%1\n\t" "bpl 1f\n\t" @@ -137,8 +121,8 @@ static inline int down_interruptible(struct semaphore * sem) "ldc r1l,ccr\n\t" "sub.l %0,%0\n\t" "2:\n\t" - : "=r" (count),"+m" (*count) - : "g"(sem) + : "=r" (count),"=m" (*count) + : "g"(sem),"m"(*count) : "cc", "er1", "er2", "er3"); return (int)count; } @@ -147,15 +131,11 @@ static inline int down_trylock(struct semaphore * sem) { register atomic_t *count asm("er0"); -#if WAITQUEUE_DEBUG - CHECK_MAGIC(sem->__magic); -#endif - count = &(sem->count); __asm__ __volatile__( "stc ccr,r3l\n\t" "orc #0x80,ccr\n\t" - "mov.l %0,er2\n\t" + "mov.l %3,er2\n\t" "dec.l #1,er2\n\t" "mov.l er2,%0\n\t" "bpl 1f\n\t" @@ -171,8 +151,8 @@ static inline int down_trylock(struct semaphore * sem) "ldc r3l,ccr\n\t" "sub.l %1,%1\n" "2:" - : "+m" (*count),"=r"(count) - : "g"(sem) + : "=m" (*count),"=r"(count) + : "g"(sem),"m"(*count) : "cc", "er1","er2", "er3"); return (int)count; } @@ -187,15 +167,11 @@ static inline void up(struct semaphore * sem) { register atomic_t *count asm("er0"); -#if WAITQUEUE_DEBUG - CHECK_MAGIC(sem->__magic); -#endif - count = &(sem->count); __asm__ __volatile__( "stc ccr,r3l\n\t" "orc #0x80,ccr\n\t" - "mov.l %0,er1\n\t" + "mov.l %2,er1\n\t" "inc.l #1,er1\n\t" "mov.l er1,%0\n\t" "ldc r3l,ccr\n\t" @@ -205,8 +181,8 @@ static inline void up(struct semaphore * sem) "mov.l %1,er0\n\t" "jsr @___up\n" "1:" - : "+m"(*count) - : "g"(sem) + : "=m"(*count) + : "g"(sem),"m"(*count) : "cc", "er1", "er2", "er3"); }