xref: /linux/arch/sh/include/asm/atomic.h (revision 561add0da6d3d07c9bccb0832fb6ed5619167d26)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_ATOMIC_H
3 #define __ASM_SH_ATOMIC_H
4 
5 #if defined(CONFIG_CPU_J2)
6 
7 #include <asm-generic/atomic.h>
8 
9 #else
10 
11 /*
12  * Atomic operations that C can't guarantee us.  Useful for
13  * resource counting etc..
14  *
15  */
16 
17 #include <linux/compiler.h>
18 #include <linux/types.h>
19 #include <asm/cmpxchg.h>
20 #include <asm/barrier.h>
21 
22 #define arch_atomic_read(v)		READ_ONCE((v)->counter)
23 #define arch_atomic_set(v,i)		WRITE_ONCE((v)->counter, (i))
24 
25 #if defined(CONFIG_GUSA_RB)
26 #include <asm/atomic-grb.h>
27 #elif defined(CONFIG_CPU_SH4A)
28 #include <asm/atomic-llsc.h>
29 #else
30 #include <asm/atomic-irq.h>
31 #endif
32 
33 #endif /* CONFIG_CPU_J2 */
34 
35 #endif /* __ASM_SH_ATOMIC_H */
36