diff options
author | Ingo Molnar <mingo@kernel.org> | 2018-07-17 10:27:43 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-07-17 10:27:43 +0300 |
commit | 52b544bd386688177c41d53e748111c29d0ccc98 (patch) | |
tree | c2083582176e773084364af93cc44e0f94b6cde8 /lib/dec_and_lock.c | |
parent | afed7bcf9487bb28e2e2b016a195085c07416c0b (diff) | |
parent | 9d3cce1e8b8561fed5f383d22a4d6949db4eadbe (diff) | |
download | linux-52b544bd386688177c41d53e748111c29d0ccc98.tar.xz |
Merge tag 'v4.18-rc5' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib/dec_and_lock.c')
-rw-r--r-- | lib/dec_and_lock.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/dec_and_lock.c b/lib/dec_and_lock.c index 347fa7ac2e8a..9555b68bb774 100644 --- a/lib/dec_and_lock.c +++ b/lib/dec_and_lock.c @@ -33,3 +33,19 @@ int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) } EXPORT_SYMBOL(_atomic_dec_and_lock); + +int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock, + unsigned long *flags) +{ + /* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */ + if (atomic_add_unless(atomic, -1, 1)) + return 0; + + /* Otherwise do it the slow way */ + spin_lock_irqsave(lock, *flags); + if (atomic_dec_and_test(atomic)) + return 1; + spin_unlock_irqrestore(lock, *flags); + return 0; +} +EXPORT_SYMBOL(_atomic_dec_and_lock_irqsave); |