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

parisc: add u16 support to cmpxchg()

Add (and export) __cmpxchg_u16(), teach __cmpxchg() to use it.

And get rid of manual truncation down to u8, etc. in there - the
only reason for those is to avoid bogus warnings about constant
truncation from sparse, and those are easy to avoid by turning
that switch into conditional expression.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

authored by

Al Viro and committed by
Paul E. McKenney
d428032b c57e5dcc

+11 -10
+9 -10
arch/parisc/include/asm/cmpxchg.h
··· 56 56 /* bug catcher for when unsupported size is used - won't link */ 57 57 extern void __cmpxchg_called_with_bad_pointer(void); 58 58 59 - /* __cmpxchg_u32/u64 defined in arch/parisc/lib/bitops.c */ 59 + /* __cmpxchg_u... defined in arch/parisc/lib/bitops.c */ 60 + extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_); 61 + extern u16 __cmpxchg_u16(volatile u16 *ptr, u16 old, u16 new_); 60 62 extern u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); 61 63 extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_); 62 - extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_); 63 64 64 65 /* don't worry...optimizer will get rid of most of this */ 65 66 static inline unsigned long 66 67 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) 67 68 { 68 - switch (size) { 69 + return 69 70 #ifdef CONFIG_64BIT 70 - case 8: return __cmpxchg_u64((u64 *)ptr, old, new_); 71 + size == 8 ? __cmpxchg_u64(ptr, old, new_) : 71 72 #endif 72 - case 4: return __cmpxchg_u32((unsigned int *)ptr, 73 - (unsigned int)old, (unsigned int)new_); 74 - case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff); 75 - } 76 - __cmpxchg_called_with_bad_pointer(); 77 - return old; 73 + size == 4 ? __cmpxchg_u32(ptr, old, new_) : 74 + size == 2 ? __cmpxchg_u16(ptr, old, new_) : 75 + size == 1 ? __cmpxchg_u8(ptr, old, new_) : 76 + (__cmpxchg_called_with_bad_pointer(), old); 78 77 } 79 78 80 79 #define arch_cmpxchg(ptr, o, n) \
+1
arch/parisc/kernel/parisc_ksyms.c
··· 23 23 EXPORT_SYMBOL(__xchg8); 24 24 EXPORT_SYMBOL(__xchg32); 25 25 EXPORT_SYMBOL(__cmpxchg_u8); 26 + EXPORT_SYMBOL(__cmpxchg_u16); 26 27 EXPORT_SYMBOL(__cmpxchg_u32); 27 28 EXPORT_SYMBOL(__cmpxchg_u64); 28 29 #ifdef CONFIG_SMP
+1
arch/parisc/lib/bitops.c
··· 71 71 72 72 CMPXCHG(u64) 73 73 CMPXCHG(u32) 74 + CMPXCHG(u16) 74 75 CMPXCHG(u8)