diff options
author | Pranith Kumar <bobby.prani@gmail.com> | 2014-09-23 10:29:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-10-03 00:06:23 -0400 |
commit | 2291059c852706c6f5ffb400366042b7625066cd (patch) | |
tree | 7827b5e7992bc0d3533d5832773c6be2f4221782 | |
parent | da4c54457e6d8262423aded4bcbccc4103049506 (diff) |
locking,arch: Use ACCESS_ONCE() instead of cast to volatile in atomic_read()
Use the much more reader friendly ACCESS_ONCE() instead of the cast to volatile.
This is purely a stylistic change.
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Link: http://lkml.kernel.org/r/1411482607-20948-1-git-send-email-bobby.prani@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/alpha/include/asm/atomic.h | 4 | ||||
-rw-r--r-- | arch/arm/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/arm64/include/asm/atomic.h | 4 | ||||
-rw-r--r-- | arch/avr32/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/cris/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/frv/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/ia64/include/asm/atomic.h | 4 | ||||
-rw-r--r-- | arch/m32r/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/m68k/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/mips/include/asm/atomic.h | 4 | ||||
-rw-r--r-- | arch/parisc/include/asm/atomic.h | 4 | ||||
-rw-r--r-- | arch/sh/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/asm/atomic_32.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/asm/atomic_64.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/atomic64_64.h | 2 | ||||
-rw-r--r-- | arch/xtensa/include/asm/atomic.h | 2 | ||||
-rw-r--r-- | include/asm-generic/atomic.h | 2 |
18 files changed, 24 insertions, 24 deletions
diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h index 6fbb53a13049..8f8eafbedd7c 100644 --- a/arch/alpha/include/asm/atomic.h +++ b/arch/alpha/include/asm/atomic.h | |||
@@ -17,8 +17,8 @@ | |||
17 | #define ATOMIC_INIT(i) { (i) } | 17 | #define ATOMIC_INIT(i) { (i) } |
18 | #define ATOMIC64_INIT(i) { (i) } | 18 | #define ATOMIC64_INIT(i) { (i) } |
19 | 19 | ||
20 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 20 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
21 | #define atomic64_read(v) (*(volatile long *)&(v)->counter) | 21 | #define atomic64_read(v) ACCESS_ONCE((v)->counter) |
22 | 22 | ||
23 | #define atomic_set(v,i) ((v)->counter = (i)) | 23 | #define atomic_set(v,i) ((v)->counter = (i)) |
24 | #define atomic64_set(v,i) ((v)->counter = (i)) | 24 | #define atomic64_set(v,i) ((v)->counter = (i)) |
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h index 832f1cdfcd6a..e22c11970b7b 100644 --- a/arch/arm/include/asm/atomic.h +++ b/arch/arm/include/asm/atomic.h | |||
@@ -27,7 +27,7 @@ | |||
27 | * strex/ldrex monitor on some implementations. The reason we can use it for | 27 | * strex/ldrex monitor on some implementations. The reason we can use it for |
28 | * atomic_set() is the clrex or dummy strex done on every exception return. | 28 | * atomic_set() is the clrex or dummy strex done on every exception return. |
29 | */ | 29 | */ |
30 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 30 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
31 | #define atomic_set(v,i) (((v)->counter) = (i)) | 31 | #define atomic_set(v,i) (((v)->counter) = (i)) |
32 | 32 | ||
33 | #if __LINUX_ARM_ARCH__ >= 6 | 33 | #if __LINUX_ARM_ARCH__ >= 6 |
diff --git a/arch/arm64/include/asm/atomic.h b/arch/arm64/include/asm/atomic.h index b83c325e587f..7047051ded40 100644 --- a/arch/arm64/include/asm/atomic.h +++ b/arch/arm64/include/asm/atomic.h | |||
@@ -35,7 +35,7 @@ | |||
35 | * strex/ldrex monitor on some implementations. The reason we can use it for | 35 | * strex/ldrex monitor on some implementations. The reason we can use it for |
36 | * atomic_set() is the clrex or dummy strex done on every exception return. | 36 | * atomic_set() is the clrex or dummy strex done on every exception return. |
37 | */ | 37 | */ |
38 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 38 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
39 | #define atomic_set(v,i) (((v)->counter) = (i)) | 39 | #define atomic_set(v,i) (((v)->counter) = (i)) |
40 | 40 | ||
41 | /* | 41 | /* |
@@ -139,7 +139,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) | |||
139 | */ | 139 | */ |
140 | #define ATOMIC64_INIT(i) { (i) } | 140 | #define ATOMIC64_INIT(i) { (i) } |
141 | 141 | ||
142 | #define atomic64_read(v) (*(volatile long *)&(v)->counter) | 142 | #define atomic64_read(v) ACCESS_ONCE((v)->counter) |
143 | #define atomic64_set(v,i) (((v)->counter) = (i)) | 143 | #define atomic64_set(v,i) (((v)->counter) = (i)) |
144 | 144 | ||
145 | #define ATOMIC64_OP(op, asm_op) \ | 145 | #define ATOMIC64_OP(op, asm_op) \ |
diff --git a/arch/avr32/include/asm/atomic.h b/arch/avr32/include/asm/atomic.h index 83e980a4e483..2d07ce1c5327 100644 --- a/arch/avr32/include/asm/atomic.h +++ b/arch/avr32/include/asm/atomic.h | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #define ATOMIC_INIT(i) { (i) } | 20 | #define ATOMIC_INIT(i) { (i) } |
21 | 21 | ||
22 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 22 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
23 | #define atomic_set(v, i) (((v)->counter) = i) | 23 | #define atomic_set(v, i) (((v)->counter) = i) |
24 | 24 | ||
25 | #define ATOMIC_OP_RETURN(op, asm_op, asm_con) \ | 25 | #define ATOMIC_OP_RETURN(op, asm_op, asm_con) \ |
diff --git a/arch/cris/include/asm/atomic.h b/arch/cris/include/asm/atomic.h index 0033f9dfea24..279766a70664 100644 --- a/arch/cris/include/asm/atomic.h +++ b/arch/cris/include/asm/atomic.h | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #define ATOMIC_INIT(i) { (i) } | 18 | #define ATOMIC_INIT(i) { (i) } |
19 | 19 | ||
20 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 20 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
21 | #define atomic_set(v,i) (((v)->counter) = (i)) | 21 | #define atomic_set(v,i) (((v)->counter) = (i)) |
22 | 22 | ||
23 | /* These should be written in asm but we do it in C for now. */ | 23 | /* These should be written in asm but we do it in C for now. */ |
diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h index f6c3a1690101..102190a61d65 100644 --- a/arch/frv/include/asm/atomic.h +++ b/arch/frv/include/asm/atomic.h | |||
@@ -31,7 +31,7 @@ | |||
31 | */ | 31 | */ |
32 | 32 | ||
33 | #define ATOMIC_INIT(i) { (i) } | 33 | #define ATOMIC_INIT(i) { (i) } |
34 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 34 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
35 | #define atomic_set(v, i) (((v)->counter) = (i)) | 35 | #define atomic_set(v, i) (((v)->counter) = (i)) |
36 | 36 | ||
37 | #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS | 37 | #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS |
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h index 42919a831c6c..0bf03501fe5c 100644 --- a/arch/ia64/include/asm/atomic.h +++ b/arch/ia64/include/asm/atomic.h | |||
@@ -21,8 +21,8 @@ | |||
21 | #define ATOMIC_INIT(i) { (i) } | 21 | #define ATOMIC_INIT(i) { (i) } |
22 | #define ATOMIC64_INIT(i) { (i) } | 22 | #define ATOMIC64_INIT(i) { (i) } |
23 | 23 | ||
24 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 24 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
25 | #define atomic64_read(v) (*(volatile long *)&(v)->counter) | 25 | #define atomic64_read(v) ACCESS_ONCE((v)->counter) |
26 | 26 | ||
27 | #define atomic_set(v,i) (((v)->counter) = (i)) | 27 | #define atomic_set(v,i) (((v)->counter) = (i)) |
28 | #define atomic64_set(v,i) (((v)->counter) = (i)) | 28 | #define atomic64_set(v,i) (((v)->counter) = (i)) |
diff --git a/arch/m32r/include/asm/atomic.h b/arch/m32r/include/asm/atomic.h index 3946b2c8d971..31bb74adba08 100644 --- a/arch/m32r/include/asm/atomic.h +++ b/arch/m32r/include/asm/atomic.h | |||
@@ -28,7 +28,7 @@ | |||
28 | * | 28 | * |
29 | * Atomically reads the value of @v. | 29 | * Atomically reads the value of @v. |
30 | */ | 30 | */ |
31 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 31 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * atomic_set - set atomic variable | 34 | * atomic_set - set atomic variable |
diff --git a/arch/m68k/include/asm/atomic.h b/arch/m68k/include/asm/atomic.h index 663d4ba2462c..e85f047fb072 100644 --- a/arch/m68k/include/asm/atomic.h +++ b/arch/m68k/include/asm/atomic.h | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #define ATOMIC_INIT(i) { (i) } | 18 | #define ATOMIC_INIT(i) { (i) } |
19 | 19 | ||
20 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 20 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
21 | #define atomic_set(v, i) (((v)->counter) = i) | 21 | #define atomic_set(v, i) (((v)->counter) = i) |
22 | 22 | ||
23 | /* | 23 | /* |
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h index f3ee721fe61d..6dd6bfc607e9 100644 --- a/arch/mips/include/asm/atomic.h +++ b/arch/mips/include/asm/atomic.h | |||
@@ -29,7 +29,7 @@ | |||
29 | * | 29 | * |
30 | * Atomically reads the value of @v. | 30 | * Atomically reads the value of @v. |
31 | */ | 31 | */ |
32 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 32 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * atomic_set - set atomic variable | 35 | * atomic_set - set atomic variable |
@@ -306,7 +306,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u) | |||
306 | * @v: pointer of type atomic64_t | 306 | * @v: pointer of type atomic64_t |
307 | * | 307 | * |
308 | */ | 308 | */ |
309 | #define atomic64_read(v) (*(volatile long *)&(v)->counter) | 309 | #define atomic64_read(v) ACCESS_ONCE((v)->counter) |
310 | 310 | ||
311 | /* | 311 | /* |
312 | * atomic64_set - set atomic variable | 312 | * atomic64_set - set atomic variable |
diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h index 219750bb4ae7..226f8ca993f6 100644 --- a/arch/parisc/include/asm/atomic.h +++ b/arch/parisc/include/asm/atomic.h | |||
@@ -67,7 +67,7 @@ static __inline__ void atomic_set(atomic_t *v, int i) | |||
67 | 67 | ||
68 | static __inline__ int atomic_read(const atomic_t *v) | 68 | static __inline__ int atomic_read(const atomic_t *v) |
69 | { | 69 | { |
70 | return (*(volatile int *)&(v)->counter); | 70 | return ACCESS_ONCE((v)->counter); |
71 | } | 71 | } |
72 | 72 | ||
73 | /* exported interface */ | 73 | /* exported interface */ |
@@ -204,7 +204,7 @@ atomic64_set(atomic64_t *v, s64 i) | |||
204 | static __inline__ s64 | 204 | static __inline__ s64 |
205 | atomic64_read(const atomic64_t *v) | 205 | atomic64_read(const atomic64_t *v) |
206 | { | 206 | { |
207 | return (*(volatile long *)&(v)->counter); | 207 | return ACCESS_ONCE((v)->counter); |
208 | } | 208 | } |
209 | 209 | ||
210 | #define atomic64_inc(v) (atomic64_add( 1,(v))) | 210 | #define atomic64_inc(v) (atomic64_add( 1,(v))) |
diff --git a/arch/sh/include/asm/atomic.h b/arch/sh/include/asm/atomic.h index f57b8a6743b3..05b9f74ce2d5 100644 --- a/arch/sh/include/asm/atomic.h +++ b/arch/sh/include/asm/atomic.h | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #define ATOMIC_INIT(i) { (i) } | 15 | #define ATOMIC_INIT(i) { (i) } |
16 | 16 | ||
17 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 17 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
18 | #define atomic_set(v,i) ((v)->counter = (i)) | 18 | #define atomic_set(v,i) ((v)->counter = (i)) |
19 | 19 | ||
20 | #if defined(CONFIG_GUSA_RB) | 20 | #if defined(CONFIG_GUSA_RB) |
diff --git a/arch/sparc/include/asm/atomic_32.h b/arch/sparc/include/asm/atomic_32.h index 7b024f02a7ce..765c1776ec9f 100644 --- a/arch/sparc/include/asm/atomic_32.h +++ b/arch/sparc/include/asm/atomic_32.h | |||
@@ -26,7 +26,7 @@ int atomic_cmpxchg(atomic_t *, int, int); | |||
26 | int __atomic_add_unless(atomic_t *, int, int); | 26 | int __atomic_add_unless(atomic_t *, int, int); |
27 | void atomic_set(atomic_t *, int); | 27 | void atomic_set(atomic_t *, int); |
28 | 28 | ||
29 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 29 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
30 | 30 | ||
31 | #define atomic_add(i, v) ((void)atomic_add_return( (int)(i), (v))) | 31 | #define atomic_add(i, v) ((void)atomic_add_return( (int)(i), (v))) |
32 | #define atomic_sub(i, v) ((void)atomic_add_return(-(int)(i), (v))) | 32 | #define atomic_sub(i, v) ((void)atomic_add_return(-(int)(i), (v))) |
diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h index 7e4ca1e73cd9..4082749913ce 100644 --- a/arch/sparc/include/asm/atomic_64.h +++ b/arch/sparc/include/asm/atomic_64.h | |||
@@ -14,8 +14,8 @@ | |||
14 | #define ATOMIC_INIT(i) { (i) } | 14 | #define ATOMIC_INIT(i) { (i) } |
15 | #define ATOMIC64_INIT(i) { (i) } | 15 | #define ATOMIC64_INIT(i) { (i) } |
16 | 16 | ||
17 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 17 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
18 | #define atomic64_read(v) (*(volatile long *)&(v)->counter) | 18 | #define atomic64_read(v) ACCESS_ONCE((v)->counter) |
19 | 19 | ||
20 | #define atomic_set(v, i) (((v)->counter) = i) | 20 | #define atomic_set(v, i) (((v)->counter) = i) |
21 | #define atomic64_set(v, i) (((v)->counter) = i) | 21 | #define atomic64_set(v, i) (((v)->counter) = i) |
diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h index bf20c817ed34..5e5cd123fdfb 100644 --- a/arch/x86/include/asm/atomic.h +++ b/arch/x86/include/asm/atomic.h | |||
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | static inline int atomic_read(const atomic_t *v) | 25 | static inline int atomic_read(const atomic_t *v) |
26 | { | 26 | { |
27 | return (*(volatile int *)&(v)->counter); | 27 | return ACCESS_ONCE((v)->counter); |
28 | } | 28 | } |
29 | 29 | ||
30 | /** | 30 | /** |
diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h index 46e9052bbd28..f8d273e18516 100644 --- a/arch/x86/include/asm/atomic64_64.h +++ b/arch/x86/include/asm/atomic64_64.h | |||
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | static inline long atomic64_read(const atomic64_t *v) | 19 | static inline long atomic64_read(const atomic64_t *v) |
20 | { | 20 | { |
21 | return (*(volatile long *)&(v)->counter); | 21 | return ACCESS_ONCE((v)->counter); |
22 | } | 22 | } |
23 | 23 | ||
24 | /** | 24 | /** |
diff --git a/arch/xtensa/include/asm/atomic.h b/arch/xtensa/include/asm/atomic.h index 626676660b80..00b7d46b35b8 100644 --- a/arch/xtensa/include/asm/atomic.h +++ b/arch/xtensa/include/asm/atomic.h | |||
@@ -47,7 +47,7 @@ | |||
47 | * | 47 | * |
48 | * Atomically reads the value of @v. | 48 | * Atomically reads the value of @v. |
49 | */ | 49 | */ |
50 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 50 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * atomic_set - set atomic variable | 53 | * atomic_set - set atomic variable |
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index 56d4d36e1531..1973ad2b13f4 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h | |||
@@ -126,7 +126,7 @@ ATOMIC_OP(or, |) | |||
126 | * Atomically reads the value of @v. | 126 | * Atomically reads the value of @v. |
127 | */ | 127 | */ |
128 | #ifndef atomic_read | 128 | #ifndef atomic_read |
129 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 129 | #define atomic_read(v) ACCESS_ONCE((v)->counter) |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | /** | 132 | /** |