Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Rich Felker | 2b47d54 | 2016-07-28 19:21:10 +0000 | [diff] [blame] | 2 | #ifndef __ASM_SH_CMPXCHG_CAS_H |
| 3 | #define __ASM_SH_CMPXCHG_CAS_H |
| 4 | |
| 5 | static inline unsigned long |
| 6 | __cmpxchg_u32(volatile u32 *m, unsigned long old, unsigned long new) |
| 7 | { |
| 8 | __asm__ __volatile__("cas.l %1,%0,@r0" |
| 9 | : "+r"(new) |
| 10 | : "r"(old), "z"(m) |
| 11 | : "t", "memory" ); |
| 12 | return new; |
| 13 | } |
| 14 | |
| 15 | static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) |
| 16 | { |
| 17 | unsigned long old; |
| 18 | do old = *m; |
| 19 | while (__cmpxchg_u32(m, old, val) != old); |
| 20 | return old; |
| 21 | } |
| 22 | |
| 23 | #include <asm/cmpxchg-xchg.h> |
| 24 | |
| 25 | #endif /* __ASM_SH_CMPXCHG_CAS_H */ |