Skip to content

Commit dbc93fd

Browse files
Al Viropaulmckrcu
authored andcommitted
sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes
trivial now Signed-off-by: Al Viro <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent d7b52b4 commit dbc93fd

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

arch/sparc/include/asm/cmpxchg_32.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,19 @@ static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ v
3838

3939
/* bug catcher for when unsupported size is used - won't link */
4040
void __cmpxchg_called_with_bad_pointer(void);
41-
/* we only need to support cmpxchg of a u32 on sparc */
41+
u8 __cmpxchg_u8(volatile u8 *m, u8 old, u8 new_);
42+
u16 __cmpxchg_u16(volatile u16 *m, u16 old, u16 new_);
4243
u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
4344

4445
/* don't worry...optimizer will get rid of most of this */
4546
static inline unsigned long
4647
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
4748
{
48-
switch (size) {
49-
case 4:
50-
return __cmpxchg_u32(ptr, old, new_);
51-
default:
52-
__cmpxchg_called_with_bad_pointer();
53-
break;
54-
}
55-
return old;
49+
return
50+
size == 1 ? __cmpxchg_u8(ptr, old, new_) :
51+
size == 2 ? __cmpxchg_u16(ptr, old, new_) :
52+
size == 4 ? __cmpxchg_u32(ptr, old, new_) :
53+
(__cmpxchg_called_with_bad_pointer(), old);
5654
}
5755

5856
#define arch_cmpxchg(ptr, o, n) \

arch/sparc/lib/atomic32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ EXPORT_SYMBOL(sp32___change_bit);
173173
return prev; \
174174
}
175175

176+
CMPXCHG(u8)
177+
CMPXCHG(u16)
176178
CMPXCHG(u32)
177179
CMPXCHG(u64)
180+
EXPORT_SYMBOL(__cmpxchg_u8);
181+
EXPORT_SYMBOL(__cmpxchg_u16);
178182
EXPORT_SYMBOL(__cmpxchg_u32);
179183
EXPORT_SYMBOL(__cmpxchg_u64);
180184

0 commit comments

Comments
 (0)