1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ARCH_H8300_CMPXCHG__
3 #define __ARCH_H8300_CMPXCHG__
5 #include <linux/irqflags.h>
8 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
11 struct __xchg_dummy { unsigned long a[100]; };
12 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
14 static inline unsigned long __xchg(unsigned long x,
15 volatile void *ptr, int size)
17 unsigned long tmp, flags;
19 local_irq_save(flags);
26 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
32 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
38 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
43 local_irq_restore(flags);
47 #include <asm-generic/cmpxchg-local.h>
50 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
53 #define cmpxchg_local(ptr, o, n) \
54 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
58 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
61 #include <asm-generic/cmpxchg.h>
64 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
66 #endif /* __ARCH_H8300_CMPXCHG__ */