From 6e6a6ef0ed1fc9652e98fcd9990959fb73e94d80 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Mon, 6 May 2013 19:13:33 +0000 Subject: [PATCH] --- yaml --- r: 374271 b: refs/heads/master c: f21dda025ab00da197ac30b6c6690c380d838683 h: refs/heads/master i: 374269: 6eb0789c86c76e75958a33d681c81fec7df05f46 374267: 896fcda4b7b3e1186e8dea46293df77760f45052 374263: fb1a54b7a34adacde325510ba9d7ee9ddd927e63 374255: 59af2cdbe70207b58fcf2da173d415cc0f2a5ba8 374239: 8a2a100f5c01ac4cfcbb7a6b5262de66e8637876 374207: 72b2e4dc9c9ac02298aa2c8de8e81d6af82c64f9 374143: dbcdd992a48298898b02480fc198eb6590456958 374015: 4bed1b954c11681a6c097d64c3e4208618317756 373759: aff92e1d6f8b32509fe6b4ff7c165de325f62478 v: v3 --- [refs] | 2 +- trunk/arch/parisc/Kconfig | 1 + trunk/arch/parisc/include/asm/atomic.h | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 3ae70e83f61e..9724d6160c1c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bbbfde782084b4f0d85ddffb88f1cf4650ff40e4 +refs/heads/master: f21dda025ab00da197ac30b6c6690c380d838683 diff --git a/trunk/arch/parisc/Kconfig b/trunk/arch/parisc/Kconfig index 433e75a2ee9a..fe4afb0f152f 100644 --- a/trunk/arch/parisc/Kconfig +++ b/trunk/arch/parisc/Kconfig @@ -13,6 +13,7 @@ config PARISC select BUG select HAVE_PERF_EVENTS select GENERIC_ATOMIC64 if !64BIT + select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_GENERIC_HARDIRQS select BROKEN_RODATA select GENERIC_IRQ_PROBE diff --git a/trunk/arch/parisc/include/asm/atomic.h b/trunk/arch/parisc/include/asm/atomic.h index f38e1984b242..472886ceab1d 100644 --- a/trunk/arch/parisc/include/asm/atomic.h +++ b/trunk/arch/parisc/include/asm/atomic.h @@ -229,6 +229,29 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) +/* + * atomic64_dec_if_positive - decrement by 1 if old value positive + * @v: pointer of type atomic_t + * + * The function returns the old value of *v minus 1, even if + * the atomic variable, v, was not decremented. + */ +static inline long atomic64_dec_if_positive(atomic64_t *v) +{ + 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 /* !CONFIG_64BIT */