diff options
| author | Vineet Gupta <Vineet.Gupta1@synopsys.com> | 2016-10-07 20:02:07 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-07 21:46:30 -0400 |
| commit | 445ed0a0eac50d2a76441278a084554a4b9dcfda (patch) | |
| tree | f3a8477d8dbe38e31a9297ca0d3a20b925b82bf8 /arch/ia64/include | |
| parent | 1061b0d21e16550e7d7893a5deee2e49ea3990ad (diff) | |
ia64: implement atomic64_dec_if_positive
This is based on s390 version and needed to get rid of
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
Link: http://lkml.kernel.org/r/1473703083-8625-2-git-send-email-vgupta@synopsys.com
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/ia64/include')
| -rw-r--r-- | arch/ia64/include/asm/atomic.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h index f565ad376142..65d4bb2b6685 100644 --- a/arch/ia64/include/asm/atomic.h +++ b/arch/ia64/include/asm/atomic.h | |||
| @@ -269,6 +269,22 @@ static __inline__ long atomic64_add_unless(atomic64_t *v, long a, long u) | |||
| 269 | 269 | ||
| 270 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) | 270 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) |
| 271 | 271 | ||
| 272 | static __inline__ long atomic64_dec_if_positive(atomic64_t *v) | ||
| 273 | { | ||
| 274 | long c, old, dec; | ||
| 275 | c = atomic64_read(v); | ||
| 276 | for (;;) { | ||
| 277 | dec = c - 1; | ||
| 278 | if (unlikely(dec < 0)) | ||
| 279 | break; | ||
| 280 | old = atomic64_cmpxchg((v), c, dec); | ||
| 281 | if (likely(old == c)) | ||
| 282 | break; | ||
| 283 | c = old; | ||
| 284 | } | ||
| 285 | return dec; | ||
| 286 | } | ||
| 287 | |||
| 272 | /* | 288 | /* |
| 273 | * Atomically add I to V and return TRUE if the resulting value is | 289 | * Atomically add I to V and return TRUE if the resulting value is |
| 274 | * negative. | 290 | * negative. |
