* [PATCH] nios2: Switch to generic __xchg()
@ 2015-09-19 4:41 Marek Vasut
2015-10-01 8:12 ` Ley Foon Tan
0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2015-09-19 4:41 UTC (permalink / raw)
To: linux-kernel; +Cc: lftan, Marek Vasut
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>
---
arch/nios2/include/asm/cmpxchg.h | 47 ----------------------------------------
1 file changed, 47 deletions(-)
diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h
index 8593871..a7978f1 100644
--- a/arch/nios2/include/asm/cmpxchg.h
+++ b/arch/nios2/include/asm/cmpxchg.h
@@ -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 */
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nios2: Switch to generic __xchg()
2015-09-19 4:41 [PATCH] nios2: Switch to generic __xchg() Marek Vasut
@ 2015-10-01 8:12 ` Ley Foon Tan
0 siblings, 0 replies; 2+ messages in thread
From: Ley Foon Tan @ 2015-10-01 8:12 UTC (permalink / raw)
To: Marek Vasut; +Cc: linux-kernel
On Sat, Sep 19, 2015 at 12:41 PM, Marek Vasut <marex@denx.de> wrote:
> 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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-01 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-19 4:41 [PATCH] nios2: Switch to generic __xchg() Marek Vasut
2015-10-01 8:12 ` Ley Foon Tan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®