Commit f3d46f9d authored by Anton Blanchard's avatar Anton Blanchard Committed by Linus Torvalds

atomic_t: Cast to volatile when accessing atomic variables

In preparation for removing volatile from the atomic_t definition, this
patch adds a volatile cast to all the atomic read functions.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e40152ee
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) #define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
#define ATOMIC64_INIT(i) ( (atomic64_t) { (i) } ) #define ATOMIC64_INIT(i) ( (atomic64_t) { (i) } )
#define atomic_read(v) ((v)->counter + 0) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) ((v)->counter + 0) #define atomic64_read(v) (*(volatile long *)&(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 @@
* 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) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(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
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
/* /*
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(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. */
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define smp_mb__after_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier()
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(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
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
#include <asm/system.h> #include <asm/system.h>
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#define ATOMIC_INIT(i) ((atomic_t) { (i) }) #define ATOMIC_INIT(i) ((atomic_t) { (i) })
#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) #define ATOMIC64_INIT(i) ((atomic64_t) { (i) })
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) ((v)->counter) #define atomic64_read(v) (*(volatile long *)&(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))
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
static inline void atomic_add(int i, atomic_t *v) static inline void atomic_add(int i, atomic_t *v)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define ATOMIC_INIT(i) { (i) } #define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i) #define atomic_set(v, i) (((v)->counter) = i)
static __inline__ void atomic_add(int i, atomic_t *v) static __inline__ void atomic_add(int i, atomic_t *v)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
/* /*
* atomic_set - set atomic variable * atomic_set - set atomic variable
...@@ -410,7 +410,7 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) ...@@ -410,7 +410,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) ((v)->counter) #define atomic64_read(v) (*(volatile long *)&(v)->counter)
/* /*
* atomic64_set - set atomic variable * atomic64_set - set atomic variable
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* Atomically reads the value of @v. Note that the guaranteed * Atomically reads the value of @v. Note that the guaranteed
* useful range of an atomic_t is only 24 bits. * useful range of an atomic_t is only 24 bits.
*/ */
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
...@@ -189,7 +189,7 @@ static __inline__ void atomic_set(atomic_t *v, int i) ...@@ -189,7 +189,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 v->counter; return (*(volatile int *)&(v)->counter);
} }
/* exported interface */ /* exported interface */
...@@ -286,7 +286,7 @@ atomic64_set(atomic64_t *v, s64 i) ...@@ -286,7 +286,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 v->counter; return (*(volatile long *)&(v)->counter);
} }
#define atomic64_add(i,v) ((void)(__atomic64_add_return( ((s64)(i)),(v)))) #define atomic64_add(i,v) ((void)(__atomic64_add_return( ((s64)(i)),(v))))
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) #define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(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)
......
...@@ -25,7 +25,7 @@ extern int atomic_cmpxchg(atomic_t *, int, int); ...@@ -25,7 +25,7 @@ extern int atomic_cmpxchg(atomic_t *, int, int);
extern int atomic_add_unless(atomic_t *, int, int); extern int atomic_add_unless(atomic_t *, int, int);
extern void atomic_set(atomic_t *, int); extern void atomic_set(atomic_t *, int);
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(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)))
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,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) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) ((v)->counter) #define atomic64_read(v) (*(volatile long *)&(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)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
static inline int atomic_read(const atomic_t *v) static inline int atomic_read(const atomic_t *v)
{ {
return v->counter; return (*(volatile int *)&(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 v->counter; return (*(volatile long *)&(v)->counter);
} }
/** /**
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
* *
* Atomically reads the value of @v. * Atomically reads the value of @v.
*/ */
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* Atomically reads the value of @v. Note that the guaranteed * Atomically reads the value of @v. Note that the guaranteed
* useful range of an atomic_t is only 24 bits. * useful range of an atomic_t is only 24 bits.
*/ */
#define atomic_read(v) ((v)->counter) #define atomic_read(v) (*(volatile int *)&(v)->counter)
/** /**
* atomic_set - set atomic variable * atomic_set - set atomic variable
......
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