diff options
Diffstat (limited to 'include/linux/freezer.h')
| -rw-r--r-- | include/linux/freezer.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index efded00ad0..08934995c7 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #define FREEZER_H_INCLUDED | 4 | #define FREEZER_H_INCLUDED |
| 5 | 5 | ||
| 6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
| 7 | #include <linux/wait.h> | ||
| 7 | 8 | ||
| 8 | #ifdef CONFIG_PM_SLEEP | 9 | #ifdef CONFIG_PM_SLEEP |
| 9 | /* | 10 | /* |
| @@ -126,6 +127,36 @@ static inline void set_freezable(void) | |||
| 126 | current->flags &= ~PF_NOFREEZE; | 127 | current->flags &= ~PF_NOFREEZE; |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 130 | /* | ||
| 131 | * Freezer-friendly wrappers around wait_event_interruptible() and | ||
| 132 | * wait_event_interruptible_timeout(), originally defined in <linux/wait.h> | ||
| 133 | */ | ||
| 134 | |||
| 135 | #define wait_event_freezable(wq, condition) \ | ||
| 136 | ({ \ | ||
| 137 | int __retval; \ | ||
| 138 | do { \ | ||
| 139 | __retval = wait_event_interruptible(wq, \ | ||
| 140 | (condition) || freezing(current)); \ | ||
| 141 | if (__retval && !freezing(current)) \ | ||
| 142 | break; \ | ||
| 143 | else if (!(condition)) \ | ||
| 144 | __retval = -ERESTARTSYS; \ | ||
| 145 | } while (try_to_freeze()); \ | ||
| 146 | __retval; \ | ||
| 147 | }) | ||
| 148 | |||
| 149 | |||
| 150 | #define wait_event_freezable_timeout(wq, condition, timeout) \ | ||
| 151 | ({ \ | ||
| 152 | long __retval = timeout; \ | ||
| 153 | do { \ | ||
| 154 | __retval = wait_event_interruptible_timeout(wq, \ | ||
| 155 | (condition) || freezing(current), \ | ||
| 156 | __retval); \ | ||
| 157 | } while (try_to_freeze()); \ | ||
| 158 | __retval; \ | ||
| 159 | }) | ||
| 129 | #else /* !CONFIG_PM_SLEEP */ | 160 | #else /* !CONFIG_PM_SLEEP */ |
| 130 | static inline int frozen(struct task_struct *p) { return 0; } | 161 | static inline int frozen(struct task_struct *p) { return 0; } |
| 131 | static inline int freezing(struct task_struct *p) { return 0; } | 162 | static inline int freezing(struct task_struct *p) { return 0; } |
| @@ -143,6 +174,13 @@ static inline void freezer_do_not_count(void) {} | |||
| 143 | static inline void freezer_count(void) {} | 174 | static inline void freezer_count(void) {} |
| 144 | static inline int freezer_should_skip(struct task_struct *p) { return 0; } | 175 | static inline int freezer_should_skip(struct task_struct *p) { return 0; } |
| 145 | static inline void set_freezable(void) {} | 176 | static inline void set_freezable(void) {} |
| 177 | |||
| 178 | #define wait_event_freezable(wq, condition) \ | ||
| 179 | wait_event_interruptible(wq, condition) | ||
| 180 | |||
| 181 | #define wait_event_freezable_timeout(wq, condition, timeout) \ | ||
| 182 | wait_event_interruptible_timeout(wq, condition, timeout) | ||
| 183 | |||
| 146 | #endif /* !CONFIG_PM_SLEEP */ | 184 | #endif /* !CONFIG_PM_SLEEP */ |
| 147 | 185 | ||
| 148 | #endif /* FREEZER_H_INCLUDED */ | 186 | #endif /* FREEZER_H_INCLUDED */ |
