X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=include%2Flinux%2Ffreezer.h;h=deddeedf32571f12015de116f729ae666f74ede4;hb=2dc75d3c3b49c64fd26b4832a7efb75546cb3fc5;hp=c8e02de737f6b07a3443d53362aee0d3bc507087;hpb=e6f194d8f6f50da6837af637b2fd839c34185f7a;p=linux-2.6-omap-h63xx.git diff --git a/include/linux/freezer.h b/include/linux/freezer.h index c8e02de737f..deddeedf325 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -4,8 +4,9 @@ #define FREEZER_H_INCLUDED #include +#include -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * Check if a process has been frozen */ @@ -126,7 +127,46 @@ static inline void set_freezable(void) current->flags &= ~PF_NOFREEZE; } -#else +/* + * Tell the freezer that the current task should be frozen by it and that it + * should send a fake signal to the task to freeze it. + */ +static inline void set_freezable_with_signal(void) +{ + current->flags &= ~(PF_NOFREEZE | PF_FREEZER_NOSIG); +} + +/* + * Freezer-friendly wrappers around wait_event_interruptible() and + * wait_event_interruptible_timeout(), originally defined in + */ + +#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 */ static inline int frozen(struct task_struct *p) { return 0; } static inline int freezing(struct task_struct *p) { return 0; } static inline void set_freeze_flag(struct task_struct *p) {} @@ -143,6 +183,14 @@ static inline void freezer_do_not_count(void) {} static inline void freezer_count(void) {} static inline int freezer_should_skip(struct task_struct *p) { return 0; } static inline void set_freezable(void) {} -#endif +static inline void set_freezable_with_signal(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 /* FREEZER_H_INCLUDED */