diff options
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 | ||