aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-06-10 19:19:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-10 19:19:40 -0400
commite7241d771419b8a8671ebc46a043c324ccb0dcf7 (patch)
tree77f1bc9c635e2ac29396816ce9ef9cbdb6853884 /kernel
parent3f6280ddf25fa656d0e17960588e52bee48a7547 (diff)
parent04dce7d9d429ea5ea04e9432d1726c930f4d67da (diff)
Merge branch 'locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: spinlock: Add missing __raw_spin_lock_flags() stub for UP mutex: add atomic_dec_and_mutex_lock(), fix locking, rtmutex.c: Documentation cleanup mutex: add atomic_dec_and_mutex_lock()
Diffstat (limited to 'kernel')
-rw-r--r--kernel/mutex.c25
-rw-r--r--kernel/rtmutex.c8
2 files changed, 28 insertions, 5 deletions
diff --git a/kernel/mutex.c b/kernel/mutex.c
index 6ca5fe96e393..e5cc0cd28d54 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -473,5 +473,28 @@ int __sched mutex_trylock(struct mutex *lock)
473 473
474 return ret; 474 return ret;
475} 475}
476
477EXPORT_SYMBOL(mutex_trylock); 476EXPORT_SYMBOL(mutex_trylock);
477
478/**
479 * atomic_dec_and_mutex_lock - return holding mutex if we dec to 0
480 * @cnt: the atomic which we are to dec
481 * @lock: the mutex to return holding if we dec to 0
482 *
483 * return true and hold lock if we dec to 0, return false otherwise
484 */
485int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock)
486{
487 /* dec if we can't possibly hit 0 */
488 if (atomic_add_unless(cnt, -1, 1))
489 return 0;
490 /* we might hit 0, so take the lock */
491 mutex_lock(lock);
492 if (!atomic_dec_and_test(cnt)) {
493 /* when we actually did the dec, we didn't hit 0 */
494 mutex_unlock(lock);
495 return 0;
496 }
497 /* we hit 0, and we hold the lock */
498 return 1;
499}
500EXPORT_SYMBOL(atomic_dec_and_mutex_lock);
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index fec77e7e0562..820c5af44f3e 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -891,9 +891,9 @@ int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock,
891EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible); 891EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible);
892 892
893/** 893/**
894 * rt_mutex_lock_interruptible_ktime - lock a rt_mutex interruptible 894 * rt_mutex_timed_lock - lock a rt_mutex interruptible
895 * the timeout structure is provided 895 * the timeout structure is provided
896 * by the caller 896 * by the caller
897 * 897 *
898 * @lock: the rt_mutex to be locked 898 * @lock: the rt_mutex to be locked
899 * @timeout: timeout structure or NULL (no timeout) 899 * @timeout: timeout structure or NULL (no timeout)
@@ -940,7 +940,7 @@ void __sched rt_mutex_unlock(struct rt_mutex *lock)
940} 940}
941EXPORT_SYMBOL_GPL(rt_mutex_unlock); 941EXPORT_SYMBOL_GPL(rt_mutex_unlock);
942 942
943/*** 943/**
944 * rt_mutex_destroy - mark a mutex unusable 944 * rt_mutex_destroy - mark a mutex unusable
945 * @lock: the mutex to be destroyed 945 * @lock: the mutex to be destroyed
946 * 946 *