commit bb1f30cb7d3ba21098f0ee7e0382160ba2599a43 Author: Oleg Nesterov Date: Fri Jun 28 09:53:57 2013 +1000 wait: introduce wait_event_common(wq, condition, state, timeout) 1. 4c663cfc "fix false timeouts when using wait_event_timeout()" is not enough, wait(wq, true, 0) still returns zero. __wait_event_timeout() was already fixed but we need the same logic in wait_event_timeout() if the fast-path check succeeds. 2. wait_event_timeout/__wait_event_timeout interface do not match wait_event(), you can't use __wait_event_timeout() instead of wait_event_timeout() if you do not need the fast-path check. Same for wait_event_interruptible/__wait_event_interruptible, so this patch cleanups rtlx.c, ip_vs_sync.c, and af_irda.c: - __wait_event_interruptible(wq, cond, ret); + ret = __wait_event_interruptible(wq, cond); 3. wait_event_* macros duplicate the same code. This patch adds a single helper wait_event_common() which hopefully does everything right. Compiler optimizes out the "dead" code when we do not need signal_pending/schedule_timeout. "size vmlinux" reports: text data bss dec hex filename - 4978601 2935080 10104832 18018513 112f0d1 vmlinux + 4977769 2930984 10104832 18013585 112dd91 vmlinux but I think this depends on gcc/config. In particular, wait_even_timeout(true, non_const_timeout) should generate more code in the non-void context because the patch adds the additional code to fix the 1st problem. Signed-off-by: Oleg Nesterov Reviewed-by: Tejun Heo Cc: Daniel Vetter Cc: Imre Deak Cc: Lukas Czerner Cc: Samuel Ortiz Cc: Wensong Zhang Cc: Simon Horman Cc: Julian Anastasov Cc: Ralf Baechle Signed-off-by: Andrew Morton