From: Chris Metcalf Date: Fri, 1 Feb 2013 17:37:48 +0000 (-0500) Subject: tile: support atomic64_dec_if_positive() X-Git-Tag: next-20130322~90^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8210b76209407d72b5490cc0c1cf09d04b204995;p=karo-tx-linux.git tile: support atomic64_dec_if_positive() Use the normal cmpxchg() idiom to implement this functionality. Signed-off-by: Chris Metcalf --- diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 0e500d90c2a0..9a9d08637ab9 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 f2461429a4a4..e71387ab20ca 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 #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 */