diff mbox series

[02/14] backports: add wait_event_killable_timeout backport support

Message ID 20180920112842.27198-3-luca@coelho.fi (mailing list archive)
State Accepted
Headers show
Series backport: updates for 4.19 | expand

Commit Message

Luca Coelho Sept. 20, 2018, 11:28 a.m. UTC
From: Shahar S Matityahu <shahar.s.matityahu@intel.com>

Allow using wait_event_killable_timeout function in kernel
older then 4.13

Signed-off-by: Shahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 backport/backport-include/linux/wait.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/wait.h b/backport/backport-include/linux/wait.h
index c4b1114e05ed..15a674cfe019 100644
--- a/backport/backport-include/linux/wait.h
+++ b/backport/backport-include/linux/wait.h
@@ -78,6 +78,21 @@  wait_on_bit_timeout(void *word, int bit, unsigned mode, unsigned long timeout)
 
 #if LINUX_VERSION_IS_LESS(4,13,0)
 #define wait_queue_entry_t wait_queue_t
+
+#define wait_event_killable_timeout(wq_head, condition, timeout)	\
+({									\
+	long __ret = timeout;						\
+	might_sleep();							\
+	if (!___wait_cond_timeout(condition))				\
+		__ret = __wait_event_killable_timeout(wq_head,		\
+						condition, timeout);	\
+	__ret;								\
+})
+
+#define __wait_event_killable_timeout(wq_head, condition, timeout)	\
+	___wait_event(wq_head, ___wait_cond_timeout(condition),		\
+		      TASK_KILLABLE, 0, timeout,			\
+		      __ret = schedule_timeout(__ret))
 #endif
 
 #endif /* __BACKPORT_LINUX_WAIT_H */