Skip to contentSkip to conversation

include/asm-*/spinlock.h cleanup

PATCH New Matti Annala 1 participant 1 message Oct 14, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/asm-*/spinlock.h cleanup

The patch below makes the spinlock.h headers in some of the include/asm-* folders more readable by removing redundant defines and simplifying the #ifdef logic a bit.

include/asm-i386/spinlock.h 2002-10-09 22:32:20.000000000 +0300 renamed from include/asm-i386/spinlock.h 2002-10-08 22:31:00.000000000 +0300 +7 -28
diff -ur --strip-trailing-cr difflinux/include/asm-i386/spinlock.h linux-2.5.41/include/asm-i386/spinlock.h
@@ -23,13 +23,11 @@
 #define SPINLOCK_MAGIC 0xdead4ead
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define SPINLOCK_MAGIC_INIT , SPINLOCK_MAGIC
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1, SPINLOCK_MAGIC }
 #else
-#define SPINLOCK_MAGIC_INIT /* */
+#define SPIN_LOCK_UNLOCKED (spinlock_t) 1
 #endif
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 SPINLOCK_MAGIC_INIT }
-
 #define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 
 /*
@@ -61,32 +59,17 @@
  */
  
 #if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE)
-
 #define spin_unlock_string \
  "movb $1,%0" \
   :"=m" (lock->lock) : : "memory"
-
-
-static inline void _raw_spin_unlock(spinlock_t *lock)
-{
-#ifdef CONFIG_DEBUG_SPINLOCK
- if (lock->magic != SPINLOCK_MAGIC)
-  BUG();
- if (!spin_is_locked(lock))
-  BUG();
-#endif
- __asm__ __volatile__(
-  spin_unlock_string
- );
-}
-
 #else
-
 #define spin_unlock_string \
  "xchgb %b0, %1" \
   :"=q" (oldval), "=m" (lock->lock) \
   :"0" (oldval) : "memory"
+#endif
 
+/* oldval is optimized away by compiler when not needed */
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
  char oldval = 1;
@@ -101,8 +84,6 @@
  );
 }
 
-#endif
-
 static inline int _raw_spin_trylock(spinlock_t *lock)
 {
  char oldval;
@@ -149,13 +130,11 @@
 #define RWLOCK_MAGIC 0xdeaf1eed
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define RWLOCK_MAGIC_INIT , RWLOCK_MAGIC
+#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS, RWLOCK_MAGIC }
 #else
-#define RWLOCK_MAGIC_INIT /* */
+#define RW_LOCK_UNLOCKED (rwlock_t) RW_LOCK_BIAS
 #endif
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT }
-
 #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
 
 #define rwlock_is_locked(x) ((x)->lock != RW_LOCK_BIAS)
@@ -189,7 +168,7 @@
  __build_write_lock(rw, "__write_lock_failed");
 }
 
-#define _raw_read_unlock(rw)  asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
+#define _raw_read_unlock(rw) asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
 #define _raw_write_unlock(rw) asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
 
 static inline int _raw_write_trylock(rwlock_t *lock)
include/asm-ia64/spinlock.h 2002-10-09 22:41:02.000000000 +0300 renamed from include/asm-ia64/spinlock.h 2002-10-09 23:20:24.000000000 +0300 +66 -75

180 lines not on this page · raw message

include/asm-ppc/spinlock.h 2002-10-09 22:48:26.000000000 +0300 renamed from include/asm-ppc/spinlock.h 2002-10-09 22:48:40.000000000 +0300 +5 -9
diff -ur --strip-trailing-cr difflinux/include/asm-ppc/spinlock.h linux-2.5.41/include/asm-ppc/spinlock.h
@@ -18,13 +18,11 @@
 
 #ifdef __KERNEL__
 #if CONFIG_DEBUG_SPINLOCK
-#define SPINLOCK_DEBUG_INIT     , 0, 0
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0 }
 #else
-#define SPINLOCK_DEBUG_INIT     /* */
+#define SPIN_LOCK_UNLOCKED (spinlock_t) 0
 #endif
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 SPINLOCK_DEBUG_INIT }
-
 #define spin_lock_init(x)  do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 #define spin_is_locked(x) ((x)->lock != 0)
 #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x))
@@ -89,14 +87,12 @@
 } rwlock_t;
 
 #if CONFIG_DEBUG_SPINLOCK
-#define RWLOCK_DEBUG_INIT     , 0
+#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
 #else
-#define RWLOCK_DEBUG_INIT     /* */
+#define RW_LOCK_UNLOCKED (rwlock_t) 0
 #endif
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { 0 RWLOCK_DEBUG_INIT }
-#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
-
+#define rwlock_init(lp)  do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
 #define rwlock_is_locked(x) ((x)->lock != 0)
 
 #ifndef CONFIG_DEBUG_SPINLOCK
include/asm-sparc/spinlock.h 2002-10-09 22:55:30.000000000 +0300 renamed from include/asm-sparc/spinlock.h 2002-10-09 22:54:02.000000000 +0300 +4 -6
diff -ur --strip-trailing-cr difflinux/include/asm-sparc/spinlock.h linux-2.5.41/include/asm-sparc/spinlock.h
@@ -13,11 +13,10 @@
 #include <asm/psr.h>
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-struct _spinlock_debug {
+typedef struct {
  unsigned char lock;
  unsigned long owner_pc;
-};
-typedef struct _spinlock_debug spinlock_t;
+} spinlock_t;
 
 #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0 }
 #define spin_lock_init(lp) do { *(lp)= SPIN_LOCK_UNLOCKED; } while(0)
@@ -32,12 +31,11 @@
 #define _raw_spin_lock(lock) _do_spin_lock(lock, "spin_lock")
 #define _raw_spin_unlock(lock) _do_spin_unlock(lock)
 
-struct _rwlock_debug {
+typedef struct {
  volatile unsigned int lock;
  unsigned long owner_pc;
  unsigned long reader_pc[NR_CPUS];
-};
-typedef struct _rwlock_debug rwlock_t;
+} rwlock_t;
 
 #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, {0} }
 
include/asm-x86_64/spinlock.h 2002-10-09 22:59:20.000000000 +0300 renamed from include/asm-x86_64/spinlock.h 2002-10-09 22:58:10.000000000 +0300 +5 -9
diff -ur --strip-trailing-cr difflinux/include/asm-x86_64/spinlock.h linux-2.5.41/include/asm-x86_64/spinlock.h
@@ -23,13 +23,11 @@
 #define SPINLOCK_MAGIC 0xdead4ead
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define SPINLOCK_MAGIC_INIT , SPINLOCK_MAGIC
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1, SPINLOCK_MAGIC }
 #else
-#define SPINLOCK_MAGIC_INIT /* */
+#define SPIN_LOCK_UNLOCKED (spinlock_t) 1
 #endif
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 SPINLOCK_MAGIC_INIT }
-
 #define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 
 /*
@@ -118,13 +116,11 @@
 #define RWLOCK_MAGIC 0xdeaf1eed
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define RWLOCK_MAGIC_INIT , RWLOCK_MAGIC
+#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS, RWLOCK_MAGIC }
 #else
-#define RWLOCK_MAGIC_INIT /* */
+#define RW_LOCK_UNLOCKED (rwlock_t) RW_LOCK_BIAS
 #endif
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT }
-
 #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
 
 /*
@@ -156,7 +152,7 @@
  __build_write_lock(rw, "__write_lock_failed");
 }
 
-#define _raw_read_unlock(rw)  asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
+#define _raw_read_unlock(rw) asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
 #define _raw_write_unlock(rw) asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
 
 static inline int _raw_write_trylock(rwlock_t *lock)