atomic.h (840B)
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#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new)) 34#define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n))) 35 36#endif /* CONFIG_CPU_J2 */ 37 38#endif /* __ASM_SH_ATOMIC_H */