diff options
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r-- | include/linux/tty.h | 42 |
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) \ | ||
632 | do { \ | ||
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 |