nios2: Switch to generic __xchg()
authorMarek Vasut <marex@denx.de>
Wed, 30 Sep 2015 14:08:00 +0000 (22:08 +0800)
committerLey Foon Tan <lftan@altera.com>
Mon, 9 Nov 2015 02:33:30 +0000 (10:33 +0800)
The generic __xchg() implementation present in asm-generic/cmpxchg.h is
correct on nios2 and even generates the same code. Switch to this generic
implementation to trim down the amount of ad-hoc copies of the code.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Ley Foon Tan <lftan@altera.com>
arch/nios2/include/asm/cmpxchg.h

index 85938711542d89182369105c670ca785ad3f3fb9..a7978f14d157c20bc8c33697076fad55b8e57434 100644 (file)
@@ -9,53 +9,6 @@
 #ifndef _ASM_NIOS2_CMPXCHG_H
 #define _ASM_NIOS2_CMPXCHG_H
 
-#include <linux/irqflags.h>
-
-#define xchg(ptr, x)   \
-       ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
-
-struct __xchg_dummy { unsigned long a[100]; };
-#define __xg(x)                ((volatile struct __xchg_dummy *)(x))
-
-static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
-                                       int size)
-{
-       unsigned long tmp, flags;
-
-       local_irq_save(flags);
-
-       switch (size) {
-       case 1:
-               __asm__ __volatile__(
-                       "ldb    %0, %2\n"
-                       "stb    %1, %2\n"
-                       : "=&r" (tmp)
-                       : "r" (x), "m" (*__xg(ptr))
-                       : "memory");
-               break;
-       case 2:
-               __asm__ __volatile__(
-                       "ldh    %0, %2\n"
-                       "sth    %1, %2\n"
-                       : "=&r" (tmp)
-                       : "r" (x), "m" (*__xg(ptr))
-                       : "memory");
-               break;
-       case 4:
-               __asm__ __volatile__(
-                       "ldw    %0, %2\n"
-                       "stw    %1, %2\n"
-                       : "=&r" (tmp)
-                       : "r" (x), "m" (*__xg(ptr))
-                       : "memory");
-               break;
-       }
-
-       local_irq_restore(flags);
-       return tmp;
-}
-
 #include <asm-generic/cmpxchg.h>
-#include <asm-generic/cmpxchg-local.h>
 
 #endif /* _ASM_NIOS2_CMPXCHG_H */