mutex: small cleanup

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, March 30, 2009 - 5:59 pm

Gitweb:     http://git.kernel.org/linus/93d81d1aca26e64a75d06a85f7e128b5f49053e7
Commit:     93d81d1aca26e64a75d06a85f7e128b5f49053e7
Parent:     a6525042bfdfcab128bd91fad264de10fd24a55e
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Wed Jan 14 15:32:51 2009 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed Jan 14 18:08:58 2009 +0100

    mutex: small cleanup
    
    Remove a local variable by combining an assingment and test in one.
    
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/mutex.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/mutex.c b/kernel/mutex.c
index 4f45d4b..357c6d2 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -129,7 +129,6 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 {
 	struct task_struct *task = current;
 	struct mutex_waiter waiter;
-	unsigned int old_val;
 	unsigned long flags;
 
 	spin_lock_mutex(&lock->wait_lock, flags);
@@ -142,8 +141,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 	list_add_tail(&waiter.list, &lock->wait_list);
 	waiter.task = task;
 
-	old_val = atomic_xchg(&lock->count, -1);
-	if (old_val == 1)
+	if (atomic_xchg(&lock->count, -1) == 1)
 		goto done;
 
 	lock_contended(&lock->dep_map, ip);
@@ -158,8 +156,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		 * that when we release the lock, we properly wake up the
 		 * other waiters:
 		 */
-		old_val = atomic_xchg(&lock->count, -1);
-		if (old_val == 1)
+		if (atomic_xchg(&lock->count, -1) == 1)
 			break;
 
 		/*
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
mutex: small cleanup, Linux Kernel Mailing ..., (Mon Mar 30, 5:59 pm)