diff options
author | Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | 2008-02-07 03:16:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:31 -0500 |
commit | 10b8827068377a11ed0e396248f7d02751fe5f17 (patch) | |
tree | 2ca6e89cc47354ac2cec717e186ede7f24e0b8fd /include/asm-blackfin | |
parent | 5e86c11d3eb4662000f3ced7344352b2ca319d03 (diff) |
Add cmpxchg_local to blackfin, replace __cmpxchg by generic cmpxchg
Use the new generic cmpxchg_local (disables interrupt). Also use the generic
cmpxchg as fallback if SMP is not set since nobody seems to know why __cmpxchg
has been implemented in assembly in the first place thather than in plain C.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Bryan Wu <bryan.wu@analog.com>
Cc: Michael Frysinger <michael.frysinger@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-blackfin')
-rw-r--r-- | include/asm-blackfin/system.h | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/include/asm-blackfin/system.h b/include/asm-blackfin/system.h index 4a927379ee1c..51494ef5bb41 100644 --- a/include/asm-blackfin/system.h +++ b/include/asm-blackfin/system.h | |||
@@ -183,55 +183,20 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, | |||
183 | return tmp; | 183 | return tmp; |
184 | } | 184 | } |
185 | 185 | ||
186 | #include <asm-generic/cmpxchg-local.h> | ||
187 | |||
186 | /* | 188 | /* |
187 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | 189 | * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make |
188 | * store NEW in MEM. Return the initial value in MEM. Success is | 190 | * them available. |
189 | * indicated by comparing RETURN with OLD. | ||
190 | */ | 191 | */ |
191 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | 192 | #define cmpxchg_local(ptr, o, n) \ |
192 | unsigned long new, int size) | 193 | ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ |
193 | { | 194 | (unsigned long)(n), sizeof(*(ptr)))) |
194 | unsigned long tmp = 0; | 195 | #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) |
195 | unsigned long flags = 0; | ||
196 | |||
197 | local_irq_save(flags); | ||
198 | |||
199 | switch (size) { | ||
200 | case 1: | ||
201 | __asm__ __volatile__ | ||
202 | ("%0 = b%3 (z);\n\t" | ||
203 | "CC = %1 == %0;\n\t" | ||
204 | "IF !CC JUMP 1f;\n\t" | ||
205 | "b%3 = %2;\n\t" | ||
206 | "1:\n\t" | ||
207 | : "=&d" (tmp) : "d" (old), "d" (new), "m" (*__xg(ptr)) : "memory"); | ||
208 | break; | ||
209 | case 2: | ||
210 | __asm__ __volatile__ | ||
211 | ("%0 = w%3 (z);\n\t" | ||
212 | "CC = %1 == %0;\n\t" | ||
213 | "IF !CC JUMP 1f;\n\t" | ||
214 | "w%3 = %2;\n\t" | ||
215 | "1:\n\t" | ||
216 | : "=&d" (tmp) : "d" (old), "d" (new), "m" (*__xg(ptr)) : "memory"); | ||
217 | break; | ||
218 | case 4: | ||
219 | __asm__ __volatile__ | ||
220 | ("%0 = %3;\n\t" | ||
221 | "CC = %1 == %0;\n\t" | ||
222 | "IF !CC JUMP 1f;\n\t" | ||
223 | "%3 = %2;\n\t" | ||
224 | "1:\n\t" | ||
225 | : "=&d" (tmp) : "d" (old), "d" (new), "m" (*__xg(ptr)) : "memory"); | ||
226 | break; | ||
227 | } | ||
228 | local_irq_restore(flags); | ||
229 | return tmp; | ||
230 | } | ||
231 | 196 | ||
232 | #define cmpxchg(ptr,o,n)\ | 197 | #ifndef CONFIG_SMP |
233 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | 198 | #include <asm-generic/cmpxchg.h> |
234 | (unsigned long)(n),sizeof(*(ptr)))) | 199 | #endif |
235 | 200 | ||
236 | #define prepare_to_switch() do { } while(0) | 201 | #define prepare_to_switch() do { } while(0) |
237 | 202 | ||