diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 01:20:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 01:20:46 -0500 |
commit | 2e6e33bab6e1996a5dec9108fb467b52b841e7a8 (patch) | |
tree | 6b98b15c2fe7899cdeb2453589cdee00f7853492 /include/asm-powerpc/atomic.h | |
parent | b7ad6d75028d021362221d9b2db19fcff995c3f8 (diff) | |
parent | b88a0b1d5560cf1959c1565617e460a45c688a08 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (78 commits)
[PATCH] powerpc: Add FSL SEC node to documentation
[PATCH] macintosh: tidy-up driver_register() return values
[PATCH] powerpc: tidy-up of_register_driver()/driver_register() return values
[PATCH] powerpc: via-pmu warning fix
[PATCH] macintosh: cleanup the use of i2c headers
[PATCH] powerpc: dont allow old RTC to be selected
[PATCH] powerpc: make powerbook_sleep_grackle static
[PATCH] powerpc: Fix warning in add_memory
[PATCH] powerpc: update mailing list addresses
[PATCH] powerpc: Remove calculation of io hole
[PATCH] powerpc: iseries: Add bootargs to /chosen
[PATCH] powerpc: iseries: Add /system-id, /model and /compatible
[PATCH] powerpc: Add strne2a() to convert a string from EBCDIC to ASCII
[PATCH] powerpc: iseries: Make more stuff static in platforms/iseries/mf.c
[PATCH] powerpc: iseries: Remove pointless iSeries_(restart|power_off|halt)
[PATCH] powerpc: iseries: mf related cleanups
[PATCH] powerpc: Replace platform_is_lpar() with a firmware feature
[PATCH] powerpc: trivial: Cleanup whitespace in cputable.h
[PATCH] powerpc: Remove unused iommu_off logic from pSeries_init_early()
[PATCH] powerpc: Unconfuse htab_bolt_mapping() callers
...
Diffstat (limited to 'include/asm-powerpc/atomic.h')
-rw-r--r-- | include/asm-powerpc/atomic.h | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h index 147a38dcc766..bb3c0ab7e667 100644 --- a/include/asm-powerpc/atomic.h +++ b/include/asm-powerpc/atomic.h | |||
@@ -8,6 +8,7 @@ | |||
8 | typedef struct { volatile int counter; } atomic_t; | 8 | typedef struct { volatile int counter; } atomic_t; |
9 | 9 | ||
10 | #ifdef __KERNEL__ | 10 | #ifdef __KERNEL__ |
11 | #include <linux/compiler.h> | ||
11 | #include <asm/synch.h> | 12 | #include <asm/synch.h> |
12 | #include <asm/asm-compat.h> | 13 | #include <asm/asm-compat.h> |
13 | 14 | ||
@@ -176,20 +177,29 @@ static __inline__ int atomic_dec_return(atomic_t *v) | |||
176 | * Atomically adds @a to @v, so long as it was not @u. | 177 | * Atomically adds @a to @v, so long as it was not @u. |
177 | * Returns non-zero if @v was not @u, and zero otherwise. | 178 | * Returns non-zero if @v was not @u, and zero otherwise. |
178 | */ | 179 | */ |
179 | #define atomic_add_unless(v, a, u) \ | 180 | static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) |
180 | ({ \ | 181 | { |
181 | int c, old; \ | 182 | int t; |
182 | c = atomic_read(v); \ | 183 | |
183 | for (;;) { \ | 184 | __asm__ __volatile__ ( |
184 | if (unlikely(c == (u))) \ | 185 | LWSYNC_ON_SMP |
185 | break; \ | 186 | "1: lwarx %0,0,%1 # atomic_add_unless\n\ |
186 | old = atomic_cmpxchg((v), c, c + (a)); \ | 187 | cmpw 0,%0,%3 \n\ |
187 | if (likely(old == c)) \ | 188 | beq- 2f \n\ |
188 | break; \ | 189 | add %0,%2,%0 \n" |
189 | c = old; \ | 190 | PPC405_ERR77(0,%2) |
190 | } \ | 191 | " stwcx. %0,0,%1 \n\ |
191 | c != (u); \ | 192 | bne- 1b \n" |
192 | }) | 193 | ISYNC_ON_SMP |
194 | " subf %0,%2,%0 \n\ | ||
195 | 2:" | ||
196 | : "=&r" (t) | ||
197 | : "r" (&v->counter), "r" (a), "r" (u) | ||
198 | : "cc", "memory"); | ||
199 | |||
200 | return t != u; | ||
201 | } | ||
202 | |||
193 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | 203 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) |
194 | 204 | ||
195 | #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) | 205 | #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) |