Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rwsem: Unify the duplicate rwsem_is_locked() inlines

Instead of having the same implementation in each architecture, move
it to linux/rwsem.h and remove the duplicates. It's unlikely that an
arch will ever implement something different, but we can deal with
that when it happens.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Matt Turner <mattst88@gmail.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Acked-by: David Miller <davem@davemloft.net>
Cc: Chris Zankel <chris@zankel.net>
LKML-Reference: <20110126195833.876773757@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+7 -40
-5
arch/alpha/include/asm/rwsem.h
··· 224 224 #endif 225 225 } 226 226 227 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 228 - { 229 - return (sem->count != 0); 230 - } 231 - 232 227 #endif /* __KERNEL__ */ 233 228 #endif /* _ALPHA_RWSEM_H */
-5
arch/ia64/include/asm/rwsem.h
··· 147 147 #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) 148 148 #define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) 149 149 150 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 151 - { 152 - return (sem->count != 0); 153 - } 154 - 155 150 #endif /* _ASM_IA64_RWSEM_H */
-5
arch/powerpc/include/asm/rwsem.h
··· 133 133 return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); 134 134 } 135 135 136 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 137 - { 138 - return sem->count != 0; 139 - } 140 - 141 136 #endif /* __KERNEL__ */ 142 137 #endif /* _ASM_POWERPC_RWSEM_H */
-5
arch/s390/include/asm/rwsem.h
··· 325 325 return new; 326 326 } 327 327 328 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 329 - { 330 - return (sem->count != 0); 331 - } 332 - 333 328 #endif /* __KERNEL__ */ 334 329 #endif /* _S390_RWSEM_H */
-5
arch/sh/include/asm/rwsem.h
··· 133 133 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 134 134 } 135 135 136 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 137 - { 138 - return (sem->count != 0); 139 - } 140 - 141 136 #endif /* __KERNEL__ */ 142 137 #endif /* _ASM_SH_RWSEM_H */
-5
arch/sparc/include/asm/rwsem.h
··· 124 124 return atomic64_add_return(delta, (atomic64_t *)(&sem->count)); 125 125 } 126 126 127 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 128 - { 129 - return (sem->count != 0); 130 - } 131 - 132 127 #endif /* __KERNEL__ */ 133 128 134 129 #endif /* _SPARC64_RWSEM_H */
-5
arch/x86/include/asm/rwsem.h
··· 222 222 return tmp + delta; 223 223 } 224 224 225 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 226 - { 227 - return (sem->count != 0); 228 - } 229 - 230 225 #endif /* __KERNEL__ */ 231 226 #endif /* _ASM_X86_RWSEM_H */
-5
arch/xtensa/include/asm/rwsem.h
··· 133 133 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 134 134 } 135 135 136 - static inline int rwsem_is_locked(struct rw_semaphore *sem) 137 - { 138 - return (sem->count != 0); 139 - } 140 - 141 136 #endif /* _XTENSA_RWSEM_H */
+7
include/linux/rwsem.h
··· 34 34 35 35 /* Include the arch specific part */ 36 36 #include <asm/rwsem.h> 37 + 38 + /* In all implementations count != 0 means locked */ 39 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 40 + { 41 + return sem->count != 0; 42 + } 43 + 37 44 #endif 38 45 39 46 /* Common initializer macros and functions */