[PATCH 14/23] make atomic_read() and atomic_set() behavior consistent on mips

From: Chris Snook
Date: Mon Aug 13 2007 - 10:31:11 EST


From: Chris Snook <csnook@xxxxxxxxxx>

Use volatile consistently in atomic.h on mips.

Signed-off-by: Chris Snook <csnook@xxxxxxxxxx>

--- linux-2.6.23-rc3-orig/include/asm-mips/atomic.h 2007-08-13 03:14:13.000000000 -0400
+++ linux-2.6.23-rc3/include/asm-mips/atomic.h 2007-08-13 05:52:14.000000000 -0400
@@ -20,7 +20,7 @@
#include <asm/war.h>
#include <asm/system.h>

-typedef struct { volatile int counter; } atomic_t;
+typedef struct { int counter; } atomic_t;

#define ATOMIC_INIT(i) { (i) }

@@ -30,7 +30,10 @@ typedef struct { volatile int counter; }
*
* Atomically reads the value of @v.
*/
-#define atomic_read(v) ((v)->counter)
+static __inline__ int atomic_read(atomic_t *v)
+{
+ return *(volatile int *)&v->counter;
+}

/*
* atomic_set - set atomic variable
@@ -39,7 +42,10 @@ typedef struct { volatile int counter; }
*
* Atomically sets the value of @v to @i.
*/
-#define atomic_set(v,i) ((v)->counter = (i))
+static __inline__ void atomic_set(atomic_t *v, int i)
+{
+ *(volatile int *)&v->counter = i;
+}

/*
* atomic_add - add integer to atomic variable
@@ -404,7 +410,7 @@ static __inline__ int atomic_add_unless(

#ifdef CONFIG_64BIT

-typedef struct { volatile long counter; } atomic64_t;
+typedef struct { long counter; } atomic64_t;

#define ATOMIC64_INIT(i) { (i) }

@@ -413,14 +419,20 @@ typedef struct { volatile long counter;
* @v: pointer of type atomic64_t
*
*/
-#define atomic64_read(v) ((v)->counter)
+static __inline__ long atomic64_read(atomic64_t *v)
+{
+ return *(volatile long *)&v->counter;
+}

/*
* atomic64_set - set atomic variable
* @v: pointer of type atomic64_t
* @i: required value
*/
-#define atomic64_set(v,i) ((v)->counter = (i))
+static __inline__ void atomic64_set(atomic64_t *v, long i)
+{
+ *(volatile long *)&v->counter = i;
+}

/*
* atomic64_add - add integer to atomic variable
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/