diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2016-12-16 20:31:17 +0300 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2016-12-16 20:31:17 +0300 |
commit | f26e8817b235d8764363bffcc9cbfc61867371f2 (patch) | |
tree | 6546ea2cf91b78f1ada2161db61e21085c880740 /include/asm-generic/mutex-xchg.h | |
parent | 2425f1808123bf69a8f66d4ec90e0d0e302c2613 (diff) | |
parent | ebfb0184ef560897fad35005989e82433419202c (diff) | |
download | linux-f26e8817b235d8764363bffcc9cbfc61867371f2.tar.xz |
Merge branch 'next' into for-linus
Prepare input updates for 4.10 merge window.
Diffstat (limited to 'include/asm-generic/mutex-xchg.h')
-rw-r--r-- | include/asm-generic/mutex-xchg.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/asm-generic/mutex-xchg.h b/include/asm-generic/mutex-xchg.h index a6b4a7bd6ac9..3269ec4e195f 100644 --- a/include/asm-generic/mutex-xchg.h +++ b/include/asm-generic/mutex-xchg.h @@ -91,8 +91,12 @@ __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *)) static inline int __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) { - int prev = atomic_xchg_acquire(count, 0); + int prev; + if (atomic_read(count) != 1) + return 0; + + prev = atomic_xchg_acquire(count, 0); if (unlikely(prev < 0)) { /* * The lock was marked contended so we must restore that |