diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-06-13 09:30:24 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-06-13 09:30:24 +1000 |
commit | 5941429f1fafd0b23b72339b23b0dcc0ca62fa01 (patch) | |
tree | d863ca45a5415f002d50be3e31c36e50131a479b /include/linux/semaphore.h | |
parent | 9a92221bd9f0a39c48748bfb250593fb84d09ff4 (diff) |
misc:introduce-down_nowait
Introduce down_try()
I planned on removing the much-disliked down_trylock() (with its
backwards return codes) in 2.6.27, but it's creating something of a
logjam with other patches in -mm and linux-next.
Andrew suggested introducing "down_try" as a wrapper now, to make
the transition easier.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'include/linux/semaphore.h')
-rw-r--r-- | include/linux/semaphore.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h index 9cae64b00d6b..537b20957ca3 100644 --- a/include/linux/semaphore.h +++ b/include/linux/semaphore.h @@ -48,4 +48,18 @@ extern int __must_check down_trylock(struct semaphore *sem); extern int __must_check down_timeout(struct semaphore *sem, long jiffies); extern void up(struct semaphore *sem); +/** + * down_try - try to down a semaphore, but don't block + * @sem: the semaphore + * + * This is equivalent to down_trylock(), but has the same return codes as + * spin_trylock and mutex_trylock: 1 if semaphore acquired, 0 if not. + * + * down_trylock() with its confusing return codes will be deprecated + * soon. It will not be missed. + */ +static inline int __must_check down_try(struct semaphore *sem) +{ + return !down_trylock(sem); +} #endif /* __LINUX_SEMAPHORE_H */ |