|
@@ -4,6 +4,7 @@
|
|
#define FREEZER_H_INCLUDED
|
|
#define FREEZER_H_INCLUDED
|
|
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/sched.h>
|
|
|
|
+#include <linux/wait.h>
|
|
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
#ifdef CONFIG_PM_SLEEP
|
|
/*
|
|
/*
|
|
@@ -126,6 +127,36 @@ static inline void set_freezable(void)
|
|
current->flags &= ~PF_NOFREEZE;
|
|
current->flags &= ~PF_NOFREEZE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Freezer-friendly wrappers around wait_event_interruptible() and
|
|
|
|
+ * wait_event_interruptible_timeout(), originally defined in <linux/wait.h>
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#define wait_event_freezable(wq, condition) \
|
|
|
|
+({ \
|
|
|
|
+ int __retval; \
|
|
|
|
+ do { \
|
|
|
|
+ __retval = wait_event_interruptible(wq, \
|
|
|
|
+ (condition) || freezing(current)); \
|
|
|
|
+ if (__retval && !freezing(current)) \
|
|
|
|
+ break; \
|
|
|
|
+ else if (!(condition)) \
|
|
|
|
+ __retval = -ERESTARTSYS; \
|
|
|
|
+ } while (try_to_freeze()); \
|
|
|
|
+ __retval; \
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#define wait_event_freezable_timeout(wq, condition, timeout) \
|
|
|
|
+({ \
|
|
|
|
+ long __retval = timeout; \
|
|
|
|
+ do { \
|
|
|
|
+ __retval = wait_event_interruptible_timeout(wq, \
|
|
|
|
+ (condition) || freezing(current), \
|
|
|
|
+ __retval); \
|
|
|
|
+ } while (try_to_freeze()); \
|
|
|
|
+ __retval; \
|
|
|
|
+})
|
|
#else /* !CONFIG_PM_SLEEP */
|
|
#else /* !CONFIG_PM_SLEEP */
|
|
static inline int frozen(struct task_struct *p) { return 0; }
|
|
static inline int frozen(struct task_struct *p) { return 0; }
|
|
static inline int freezing(struct task_struct *p) { return 0; }
|
|
static inline int freezing(struct task_struct *p) { return 0; }
|
|
@@ -143,6 +174,13 @@ static inline void freezer_do_not_count(void) {}
|
|
static inline void freezer_count(void) {}
|
|
static inline void freezer_count(void) {}
|
|
static inline int freezer_should_skip(struct task_struct *p) { return 0; }
|
|
static inline int freezer_should_skip(struct task_struct *p) { return 0; }
|
|
static inline void set_freezable(void) {}
|
|
static inline void set_freezable(void) {}
|
|
|
|
+
|
|
|
|
+#define wait_event_freezable(wq, condition) \
|
|
|
|
+ wait_event_interruptible(wq, condition)
|
|
|
|
+
|
|
|
|
+#define wait_event_freezable_timeout(wq, condition, timeout) \
|
|
|
|
+ wait_event_interruptible_timeout(wq, condition, timeout)
|
|
|
|
+
|
|
#endif /* !CONFIG_PM_SLEEP */
|
|
#endif /* !CONFIG_PM_SLEEP */
|
|
|
|
|
|
#endif /* FREEZER_H_INCLUDED */
|
|
#endif /* FREEZER_H_INCLUDED */
|