summaryrefslogtreecommitdiff
path: root/include/linux/semaphore.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/semaphore.h')
-rw-r--r--include/linux/semaphore.h14
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 */