Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/atomic: Move ATOMIC_INIT into linux/types.h

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

authored by

Herbert Xu and committed by
Peter Zijlstra
7ca8cf53 e885d5d9

+2 -34
-1
arch/alpha/include/asm/atomic.h
··· 24 24 #define __atomic_acquire_fence() 25 25 #define __atomic_post_full_fence() 26 26 27 - #define ATOMIC_INIT(i) { (i) } 28 27 #define ATOMIC64_INIT(i) { (i) } 29 28 30 29 #define atomic_read(v) READ_ONCE((v)->counter)
-2
arch/arc/include/asm/atomic.h
··· 14 14 #include <asm/barrier.h> 15 15 #include <asm/smp.h> 16 16 17 - #define ATOMIC_INIT(i) { (i) } 18 - 19 17 #ifndef CONFIG_ARC_PLAT_EZNPS 20 18 21 19 #define atomic_read(v) READ_ONCE((v)->counter)
-2
arch/arm/include/asm/atomic.h
··· 15 15 #include <asm/barrier.h> 16 16 #include <asm/cmpxchg.h> 17 17 18 - #define ATOMIC_INIT(i) { (i) } 19 - 20 18 #ifdef __KERNEL__ 21 19 22 20 /*
-2
arch/arm64/include/asm/atomic.h
··· 99 99 return __lse_ll_sc_body(atomic64_dec_if_positive, v); 100 100 } 101 101 102 - #define ATOMIC_INIT(i) { (i) } 103 - 104 102 #define arch_atomic_read(v) __READ_ONCE((v)->counter) 105 103 #define arch_atomic_set(v, i) __WRITE_ONCE(((v)->counter), (i)) 106 104
-2
arch/h8300/include/asm/atomic.h
··· 12 12 * resource counting etc.. 13 13 */ 14 14 15 - #define ATOMIC_INIT(i) { (i) } 16 - 17 15 #define atomic_read(v) READ_ONCE((v)->counter) 18 16 #define atomic_set(v, i) WRITE_ONCE(((v)->counter), (i)) 19 17
-2
arch/hexagon/include/asm/atomic.h
··· 12 12 #include <asm/cmpxchg.h> 13 13 #include <asm/barrier.h> 14 14 15 - #define ATOMIC_INIT(i) { (i) } 16 - 17 15 /* Normal writes in our arch don't clear lock reservations */ 18 16 19 17 static inline void atomic_set(atomic_t *v, int new)
-1
arch/ia64/include/asm/atomic.h
··· 19 19 #include <asm/barrier.h> 20 20 21 21 22 - #define ATOMIC_INIT(i) { (i) } 23 22 #define ATOMIC64_INIT(i) { (i) } 24 23 25 24 #define atomic_read(v) READ_ONCE((v)->counter)
-2
arch/m68k/include/asm/atomic.h
··· 16 16 * We do not have SMP m68k systems, so we don't have to deal with that. 17 17 */ 18 18 19 - #define ATOMIC_INIT(i) { (i) } 20 - 21 19 #define atomic_read(v) READ_ONCE((v)->counter) 22 20 #define atomic_set(v, i) WRITE_ONCE(((v)->counter), (i)) 23 21
-1
arch/mips/include/asm/atomic.h
··· 45 45 return xchg(&v->counter, n); \ 46 46 } 47 47 48 - #define ATOMIC_INIT(i) { (i) } 49 48 ATOMIC_OPS(atomic, int) 50 49 51 50 #ifdef CONFIG_64BIT
-2
arch/parisc/include/asm/atomic.h
··· 136 136 #undef ATOMIC_OP_RETURN 137 137 #undef ATOMIC_OP 138 138 139 - #define ATOMIC_INIT(i) { (i) } 140 - 141 139 #ifdef CONFIG_64BIT 142 140 143 141 #define ATOMIC64_INIT(i) { (i) }
-2
arch/powerpc/include/asm/atomic.h
··· 11 11 #include <asm/cmpxchg.h> 12 12 #include <asm/barrier.h> 13 13 14 - #define ATOMIC_INIT(i) { (i) } 15 - 16 14 /* 17 15 * Since *_return_relaxed and {cmp}xchg_relaxed are implemented with 18 16 * a "bne-" instruction at the end, so an isync is enough as a acquire barrier
-2
arch/riscv/include/asm/atomic.h
··· 19 19 #include <asm/cmpxchg.h> 20 20 #include <asm/barrier.h> 21 21 22 - #define ATOMIC_INIT(i) { (i) } 23 - 24 22 #define __atomic_acquire_fence() \ 25 23 __asm__ __volatile__(RISCV_ACQUIRE_BARRIER "" ::: "memory") 26 24
-2
arch/s390/include/asm/atomic.h
··· 15 15 #include <asm/barrier.h> 16 16 #include <asm/cmpxchg.h> 17 17 18 - #define ATOMIC_INIT(i) { (i) } 19 - 20 18 static inline int atomic_read(const atomic_t *v) 21 19 { 22 20 int c;
-2
arch/sh/include/asm/atomic.h
··· 19 19 #include <asm/cmpxchg.h> 20 20 #include <asm/barrier.h> 21 21 22 - #define ATOMIC_INIT(i) { (i) } 23 - 24 22 #define atomic_read(v) READ_ONCE((v)->counter) 25 23 #define atomic_set(v,i) WRITE_ONCE((v)->counter, (i)) 26 24
-2
arch/sparc/include/asm/atomic_32.h
··· 18 18 #include <asm/barrier.h> 19 19 #include <asm-generic/atomic64.h> 20 20 21 - #define ATOMIC_INIT(i) { (i) } 22 - 23 21 int atomic_add_return(int, atomic_t *); 24 22 int atomic_fetch_add(int, atomic_t *); 25 23 int atomic_fetch_and(int, atomic_t *);
-1
arch/sparc/include/asm/atomic_64.h
··· 12 12 #include <asm/cmpxchg.h> 13 13 #include <asm/barrier.h> 14 14 15 - #define ATOMIC_INIT(i) { (i) } 16 15 #define ATOMIC64_INIT(i) { (i) } 17 16 18 17 #define atomic_read(v) READ_ONCE((v)->counter)
-2
arch/x86/include/asm/atomic.h
··· 14 14 * resource counting etc.. 15 15 */ 16 16 17 - #define ATOMIC_INIT(i) { (i) } 18 - 19 17 /** 20 18 * arch_atomic_read - read atomic variable 21 19 * @v: pointer of type atomic_t
-2
arch/xtensa/include/asm/atomic.h
··· 19 19 #include <asm/cmpxchg.h> 20 20 #include <asm/barrier.h> 21 21 22 - #define ATOMIC_INIT(i) { (i) } 23 - 24 22 /* 25 23 * This Xtensa implementation assumes that the right mechanism 26 24 * for exclusion is for locking interrupts to level EXCM_LEVEL.
-2
include/asm-generic/atomic.h
··· 159 159 * resource counting etc.. 160 160 */ 161 161 162 - #define ATOMIC_INIT(i) { (i) } 163 - 164 162 /** 165 163 * atomic_read - read atomic variable 166 164 * @v: pointer of type atomic_t
+2
include/linux/types.h
··· 167 167 int counter; 168 168 } atomic_t; 169 169 170 + #define ATOMIC_INIT(i) { (i) } 171 + 170 172 #ifdef CONFIG_64BIT 171 173 typedef struct { 172 174 s64 counter;