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>
This commit is contained in:
parent
c57e5dccb0
commit
d428032b35
@ -56,25 +56,24 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size)
|
|||||||
/* bug catcher for when unsupported size is used - won't link */
|
/* bug catcher for when unsupported size is used - won't link */
|
||||||
extern void __cmpxchg_called_with_bad_pointer(void);
|
extern void __cmpxchg_called_with_bad_pointer(void);
|
||||||
|
|
||||||
/* __cmpxchg_u32/u64 defined in arch/parisc/lib/bitops.c */
|
/* __cmpxchg_u... defined in arch/parisc/lib/bitops.c */
|
||||||
|
extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_);
|
||||||
|
extern u16 __cmpxchg_u16(volatile u16 *ptr, u16 old, u16 new_);
|
||||||
extern u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
|
extern u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
|
||||||
extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_);
|
extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_);
|
||||||
extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_);
|
|
||||||
|
|
||||||
/* don't worry...optimizer will get rid of most of this */
|
/* don't worry...optimizer will get rid of most of this */
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
|
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
|
||||||
{
|
{
|
||||||
switch (size) {
|
return
|
||||||
#ifdef CONFIG_64BIT
|
#ifdef CONFIG_64BIT
|
||||||
case 8: return __cmpxchg_u64((u64 *)ptr, old, new_);
|
size == 8 ? __cmpxchg_u64(ptr, old, new_) :
|
||||||
#endif
|
#endif
|
||||||
case 4: return __cmpxchg_u32((unsigned int *)ptr,
|
size == 4 ? __cmpxchg_u32(ptr, old, new_) :
|
||||||
(unsigned int)old, (unsigned int)new_);
|
size == 2 ? __cmpxchg_u16(ptr, old, new_) :
|
||||||
case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff);
|
size == 1 ? __cmpxchg_u8(ptr, old, new_) :
|
||||||
}
|
(__cmpxchg_called_with_bad_pointer(), old);
|
||||||
__cmpxchg_called_with_bad_pointer();
|
|
||||||
return old;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define arch_cmpxchg(ptr, o, n) \
|
#define arch_cmpxchg(ptr, o, n) \
|
||||||
|
|||||||
@ -23,6 +23,7 @@ EXPORT_SYMBOL(memset);
|
|||||||
EXPORT_SYMBOL(__xchg8);
|
EXPORT_SYMBOL(__xchg8);
|
||||||
EXPORT_SYMBOL(__xchg32);
|
EXPORT_SYMBOL(__xchg32);
|
||||||
EXPORT_SYMBOL(__cmpxchg_u8);
|
EXPORT_SYMBOL(__cmpxchg_u8);
|
||||||
|
EXPORT_SYMBOL(__cmpxchg_u16);
|
||||||
EXPORT_SYMBOL(__cmpxchg_u32);
|
EXPORT_SYMBOL(__cmpxchg_u32);
|
||||||
EXPORT_SYMBOL(__cmpxchg_u64);
|
EXPORT_SYMBOL(__cmpxchg_u64);
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
|||||||
@ -71,4 +71,5 @@ unsigned long notrace __xchg8(char x, volatile char *ptr)
|
|||||||
|
|
||||||
CMPXCHG(u64)
|
CMPXCHG(u64)
|
||||||
CMPXCHG(u32)
|
CMPXCHG(u32)
|
||||||
|
CMPXCHG(u16)
|
||||||
CMPXCHG(u8)
|
CMPXCHG(u8)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user