Commit 2291059c authored by Pranith Kumar's avatar Pranith Kumar Committed by Ingo Molnar

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: default avatarPranith Kumar <bobby.prani@gmail.com>
Acked-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
Acked-by: default avatarHans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: default avatarPeter 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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent da4c5445
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define ATOMIC64_INIT(i) { (i) } #define ATOMIC64_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter) #define atomic64_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) ((v)->counter = (i)) #define atomic_set(v,i) ((v)->counter = (i))
#define atomic64_set(v,i) ((v)->counter = (i)) #define atomic64_set(v,i) ((v)->counter = (i))
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* strex/ldrex monitor on some implementations. The reason we can use it for * strex/ldrex monitor on some implementations. The reason we can use it for
* atomic_set() is the clrex or dummy strex done on every exception return. * atomic_set() is the clrex or dummy strex done on every exception return.
*/ */
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i)) #define atomic_set(v,i) (((v)->counter) = (i))
#if __LINUX_ARM_ARCH__ >= 6 #if __LINUX_ARM_ARCH__ >= 6
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* strex/ldrex monitor on some implementations. The reason we can use it for * strex/ldrex monitor on some implementations. The reason we can use it for
* atomic_set() is the clrex or dummy strex done on every exception return. * atomic_set() is the clrex or dummy strex done on every exception return.
*/ */
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i)) #define atomic_set(v,i) (((v)->counter) = (i))
/* /*
...@@ -139,7 +139,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) ...@@ -139,7 +139,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
*/ */
#define ATOMIC64_INIT(i) { (i) } #define ATOMIC64_INIT(i) { (i) }
#define atomic64_read(v) (*(volatile long *)&(v)->counter) #define atomic64_read(v) ACCESS_ONCE((v)->counter)
#define atomic64_set(v,i) (((v)->counter) = (i)) #define atomic64_set(v,i) (((v)->counter) = (i))
#define ATOMIC64_OP(op, asm_op) \ #define ATOMIC64_OP(op, asm_op) \
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
#define ATOMIC_OP_RETURN(op, asm_op, asm_con) \ #define ATOMIC_OP_RETURN(op, asm_op, asm_con) \
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i)) #define atomic_set(v,i) (((v)->counter) = (i))
/* These should be written in asm but we do it in C for now. */ /* These should be written in asm but we do it in C for now. */
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
*/ */
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v, i) (((v)->counter) = (i)) #define atomic_set(v, i) (((v)->counter) = (i))
#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define ATOMIC64_INIT(i) { (i) } #define ATOMIC64_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter) #define atomic64_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i)) #define atomic_set(v,i) (((v)->counter) = (i))
#define atomic64_set(v,i) (((v)->counter) = (i)) #define atomic64_set(v,i) (((v)->counter) = (i))
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
/* /*
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
/* /*
* atomic_set - set atomic variable * atomic_set - set atomic variable
...@@ -306,7 +306,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u) ...@@ -306,7 +306,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
* @v: pointer of type atomic64_t * @v: pointer of type atomic64_t
* *
*/ */
#define atomic64_read(v) (*(volatile long *)&(v)->counter) #define atomic64_read(v) ACCESS_ONCE((v)->counter)
/* /*
* atomic64_set - set atomic variable * atomic64_set - set atomic variable
......
...@@ -67,7 +67,7 @@ static __inline__ void atomic_set(atomic_t *v, int i) ...@@ -67,7 +67,7 @@ static __inline__ void atomic_set(atomic_t *v, int i)
static __inline__ int atomic_read(const atomic_t *v) static __inline__ int atomic_read(const atomic_t *v)
{ {
return (*(volatile int *)&(v)->counter); return ACCESS_ONCE((v)->counter);
} }
/* exported interface */ /* exported interface */
...@@ -204,7 +204,7 @@ atomic64_set(atomic64_t *v, s64 i) ...@@ -204,7 +204,7 @@ atomic64_set(atomic64_t *v, s64 i)
static __inline__ s64 static __inline__ s64
atomic64_read(const atomic64_t *v) atomic64_read(const atomic64_t *v)
{ {
return (*(volatile long *)&(v)->counter); return ACCESS_ONCE((v)->counter);
} }
#define atomic64_inc(v) (atomic64_add( 1,(v))) #define atomic64_inc(v) (atomic64_add( 1,(v)))
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v,i) ((v)->counter = (i)) #define atomic_set(v,i) ((v)->counter = (i))
#if defined(CONFIG_GUSA_RB) #if defined(CONFIG_GUSA_RB)
......
...@@ -26,7 +26,7 @@ int atomic_cmpxchg(atomic_t *, int, int); ...@@ -26,7 +26,7 @@ int atomic_cmpxchg(atomic_t *, int, int);
int __atomic_add_unless(atomic_t *, int, int); int __atomic_add_unless(atomic_t *, int, int);
void atomic_set(atomic_t *, int); void atomic_set(atomic_t *, int);
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic_add(i, v) ((void)atomic_add_return( (int)(i), (v))) #define atomic_add(i, v) ((void)atomic_add_return( (int)(i), (v)))
#define atomic_sub(i, v) ((void)atomic_add_return(-(int)(i), (v))) #define atomic_sub(i, v) ((void)atomic_add_return(-(int)(i), (v)))
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define ATOMIC64_INIT(i) { (i) } #define ATOMIC64_INIT(i) { (i) }
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter) #define atomic64_read(v) ACCESS_ONCE((v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
#define atomic64_set(v, i) (((v)->counter) = i) #define atomic64_set(v, i) (((v)->counter) = i)
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
*/ */
static inline int atomic_read(const atomic_t *v) static inline int atomic_read(const atomic_t *v)
{ {
return (*(volatile int *)&(v)->counter); return ACCESS_ONCE((v)->counter);
} }
/** /**
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
static inline long atomic64_read(const atomic64_t *v) static inline long atomic64_read(const atomic64_t *v)
{ {
return (*(volatile long *)&(v)->counter); return ACCESS_ONCE((v)->counter);
} }
/** /**
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
...@@ -126,7 +126,7 @@ ATOMIC_OP(or, |) ...@@ -126,7 +126,7 @@ ATOMIC_OP(or, |)
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#ifndef atomic_read #ifndef atomic_read
#define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_read(v) ACCESS_ONCE((v)->counter)
#endif #endif
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment