1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_ATOMIC_H
3 #define __ASM_SH_ATOMIC_H
5 #if defined(CONFIG_CPU_J2)
7 #include <asm-generic/atomic.h>
12 * Atomic operations that C can't guarantee us. Useful for
13 * resource counting etc..
17 #include <linux/compiler.h>
18 #include <linux/types.h>
19 #include <asm/cmpxchg.h>
20 #include <asm/barrier.h>
22 #define ATOMIC_INIT(i) { (i) }
24 #define atomic_read(v) READ_ONCE((v)->counter)
25 #define atomic_set(v,i) WRITE_ONCE((v)->counter, (i))
27 #if defined(CONFIG_GUSA_RB)
28 #include <asm/atomic-grb.h>
29 #elif defined(CONFIG_CPU_SH4A)
30 #include <asm/atomic-llsc.h>
32 #include <asm/atomic-irq.h>
35 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
36 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
38 #endif /* CONFIG_CPU_J2 */
40 #endif /* __ASM_SH_ATOMIC_H */