projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1061b0d
)
ia64: implement atomic64_dec_if_positive
author
Vineet Gupta
<
[email protected]
>
Sat, 8 Oct 2016 00:02:07 +0000
(17:02 -0700)
committer
Linus Torvalds
<
[email protected]
>
Sat, 8 Oct 2016 01:46:30 +0000
(18:46 -0700)
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/
[email protected]
Signed-off-by: Vineet Gupta <
[email protected]
>
Reported-by: kbuild test robot <
[email protected]
>
Cc: Tony Luck <
[email protected]
>
Cc: Fenghua Yu <
[email protected]
>
Cc: Ingo Molnar <
[email protected]
>
Cc: Peter Zijlstra <
[email protected]
>
Signed-off-by: Andrew Morton <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
arch/ia64/include/asm/atomic.h
patch
|
blob
|
history
diff --git
a/arch/ia64/include/asm/atomic.h
b/arch/ia64/include/asm/atomic.h
index f565ad3761427afb14625ee612bdb6067c8d28c2..65d4bb2b6685978f708f34aebf4cd2d00ac4681b 100644
(file)
--- 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)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+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;
+}
+
/*
* Atomically add I to V and return TRUE if the resulting value is
* negative.