diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2024-04-01 22:17:49 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2024-04-09 22:06:00 -0700 |
commit | dbc93fdcdc0d4df7abad10aac14326a4a9975997 (patch) | |
tree | 08ff4b171a82cd2ae51572aded2a8624c66a59b7 /arch/sparc/include | |
parent | d7b52b48f006ea3dd2e682097a91eeda9dfb3df9 (diff) |
sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes
trivial now
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'arch/sparc/include')
-rw-r--r-- | arch/sparc/include/asm/cmpxchg_32.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h index 05d5f86a56dc..8c1a3ca34eeb 100644 --- a/arch/sparc/include/asm/cmpxchg_32.h +++ b/arch/sparc/include/asm/cmpxchg_32.h @@ -38,21 +38,19 @@ static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ v /* bug catcher for when unsupported size is used - won't link */ void __cmpxchg_called_with_bad_pointer(void); -/* we only need to support cmpxchg of a u32 on sparc */ +u8 __cmpxchg_u8(volatile u8 *m, u8 old, u8 new_); +u16 __cmpxchg_u16(volatile u16 *m, u16 old, u16 new_); u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); /* don't worry...optimizer will get rid of most of this */ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) { - switch (size) { - case 4: - return __cmpxchg_u32(ptr, old, new_); - default: - __cmpxchg_called_with_bad_pointer(); - break; - } - return old; + return + size == 1 ? __cmpxchg_u8(ptr, old, new_) : + size == 2 ? __cmpxchg_u16(ptr, old, new_) : + size == 4 ? __cmpxchg_u32(ptr, old, new_) : + (__cmpxchg_called_with_bad_pointer(), old); } #define arch_cmpxchg(ptr, o, n) \ |