diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-12-12 08:09:03 (GMT) |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-12-12 08:09:03 (GMT) |
commit | 3459f0d78ffe27a1b341c22eb158b622eaaea3fc (patch) | |
tree | 715b0575eec541d0181876ad367ca5480cdcecf3 /arch/nios2/include/asm/cmpxchg.h | |
parent | 9fc81d87420d0d3fd62d5e5529972c0ad9eab9cc (diff) | |
parent | bee2782f30f66898be3f74ad02e4d1f87a969694 (diff) | |
download | linux-3459f0d78ffe27a1b341c22eb158b622eaaea3fc.tar.xz |
Merge branch 'linus' into perf/urgent, to pick up the upstream merged bits
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/nios2/include/asm/cmpxchg.h')
-rw-r--r-- | arch/nios2/include/asm/cmpxchg.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h new file mode 100644 index 0000000..8593871 --- /dev/null +++ b/arch/nios2/include/asm/cmpxchg.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004 Microtronix Datacom Ltd. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + +#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 */ |