summaryrefslogtreecommitdiff
path: root/include/asm-generic/mutex-xchg.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2016-12-16 20:31:17 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-12-16 20:31:17 +0300
commitf26e8817b235d8764363bffcc9cbfc61867371f2 (patch)
tree6546ea2cf91b78f1ada2161db61e21085c880740 /include/asm-generic/mutex-xchg.h
parent2425f1808123bf69a8f66d4ec90e0d0e302c2613 (diff)
parentebfb0184ef560897fad35005989e82433419202c (diff)
downloadlinux-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.h6
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