aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tty.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-01 16:53:05 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 16:47:43 -0400
commitbe1bc2889a4db4961ef69f47fb471ecae9f23ade (patch)
treefd6d5e46e69efd9d66e6baa184988461f608f49a /include/linux/tty.h
parent4e608671674b62e97166f903830d5553e37970e8 (diff)
tty: introduce wait_event_interruptible_tty
Calling wait_event_interruptible implicitly releases the BKL when it sleeps, but we need to do this explcitly when we have converted it to a mutex. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r--include/linux/tty.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 6ead6b60c743..955d72ea71c0 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -607,5 +607,47 @@ static inline void tty_unlock(void) __releases(kernel_lock)
607} 607}
608#define tty_locked() (kernel_locked()) 608#define tty_locked() (kernel_locked())
609 609
610/*
611 * wait_event_interruptible_tty -- wait for a condition with the tty lock held
612 *
613 * The condition we are waiting for might take a long time to
614 * become true, or might depend on another thread taking the
615 * BTM. In either case, we need to drop the BTM to guarantee
616 * forward progress. This is a leftover from the conversion
617 * from the BKL and should eventually get removed as the BTM
618 * falls out of use.
619 *
620 * Do not use in new code.
621 */
622#define wait_event_interruptible_tty(wq, condition) \
623({ \
624 int __ret = 0; \
625 if (!(condition)) { \
626 __wait_event_interruptible_tty(wq, condition, __ret); \
627 } \
628 __ret; \
629})
630
631#define __wait_event_interruptible_tty(wq, condition, ret) \
632do { \
633 DEFINE_WAIT(__wait); \
634 \
635 for (;;) { \
636 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
637 if (condition) \
638 break; \
639 if (!signal_pending(current)) { \
640 tty_unlock(); \
641 schedule(); \
642 tty_lock(); \
643 continue; \
644 } \
645 ret = -ERESTARTSYS; \
646 break; \
647 } \
648 finish_wait(&wq, &__wait); \
649} while (0)
650
651
610#endif /* __KERNEL__ */ 652#endif /* __KERNEL__ */
611#endif 653#endif