mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-16 23:45:31 +08:00
7ca8cf5347
This patch moves ATOMIC_INIT from asm/atomic.h into linux/types.h. This allows users of atomic_t to use ATOMIC_INIT without having to include atomic.h as that way may lead to header loops. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Waiman Long <longman@redhat.com> Link: https://lkml.kernel.org/r/20200729123105.GB7047@gondor.apana.org.au
39 lines
812 B
C
39 lines
812 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_SH_ATOMIC_H
|
|
#define __ASM_SH_ATOMIC_H
|
|
|
|
#if defined(CONFIG_CPU_J2)
|
|
|
|
#include <asm-generic/atomic.h>
|
|
|
|
#else
|
|
|
|
/*
|
|
* Atomic operations that C can't guarantee us. Useful for
|
|
* resource counting etc..
|
|
*
|
|
*/
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include <asm/cmpxchg.h>
|
|
#include <asm/barrier.h>
|
|
|
|
#define atomic_read(v) READ_ONCE((v)->counter)
|
|
#define atomic_set(v,i) WRITE_ONCE((v)->counter, (i))
|
|
|
|
#if defined(CONFIG_GUSA_RB)
|
|
#include <asm/atomic-grb.h>
|
|
#elif defined(CONFIG_CPU_SH4A)
|
|
#include <asm/atomic-llsc.h>
|
|
#else
|
|
#include <asm/atomic-irq.h>
|
|
#endif
|
|
|
|
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
|
|
#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
|
|
|
|
#endif /* CONFIG_CPU_J2 */
|
|
|
|
#endif /* __ASM_SH_ATOMIC_H */
|