diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2013-02-01 12:37:48 -0500 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2013-03-22 15:47:00 -0400 |
commit | adf6d9b30f089c52e674e84ca2960581e504e5e3 (patch) | |
tree | f680f2877480201116e54da1e6a1af848884d646 /arch/tile | |
parent | ef567f25d5d9d803b89bc2aec6bb71fe8b4bebd9 (diff) | |
download | op-kernel-dev-adf6d9b30f089c52e674e84ca2960581e504e5e3.zip op-kernel-dev-adf6d9b30f089c52e674e84ca2960581e504e5e3.tar.gz |
tile: support atomic64_dec_if_positive()
Use the normal cmpxchg() idiom to implement this functionality.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile')
-rw-r--r-- | arch/tile/Kconfig | 1 | ||||
-rw-r--r-- | arch/tile/include/asm/atomic.h | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 0e500d9..9a9d086 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -24,6 +24,7 @@ config TILE select MODULES_USE_ELF_RELA select HAVE_ARCH_TRACEHOOK select HAVE_SYSCALL_TRACEPOINTS + select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE # FIXME: investigate whether we need/want these options. # select HAVE_IOREMAP_PROT diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h index f246142..e71387a 100644 --- a/arch/tile/include/asm/atomic.h +++ b/arch/tile/include/asm/atomic.h @@ -131,4 +131,25 @@ static inline int atomic_read(const atomic_t *v) #include <asm/atomic_64.h> #endif +#ifndef __ASSEMBLY__ + +static inline long long atomic64_dec_if_positive(atomic64_t *v) +{ + long long c, old, dec; + + c = atomic64_read(v); + for (;;) { + dec = c - 1; + if (unlikely(dec < 0)) + break; + old = atomic64_cmpxchg((v), c, dec); + if (likely(old == c)) + break; + c = old; + } + return dec; +} + +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_TILE_ATOMIC_H */ |