Lines Matching refs:tty
49 int tty_chars_in_buffer(struct tty_struct *tty) in tty_chars_in_buffer() argument
51 if (tty->ops->chars_in_buffer) in tty_chars_in_buffer()
52 return tty->ops->chars_in_buffer(tty); in tty_chars_in_buffer()
69 int tty_write_room(struct tty_struct *tty) in tty_write_room() argument
71 if (tty->ops->write_room) in tty_write_room()
72 return tty->ops->write_room(tty); in tty_write_room()
85 void tty_driver_flush_buffer(struct tty_struct *tty) in tty_driver_flush_buffer() argument
87 if (tty->ops->flush_buffer) in tty_driver_flush_buffer()
88 tty->ops->flush_buffer(tty); in tty_driver_flush_buffer()
102 void tty_throttle(struct tty_struct *tty) in tty_throttle() argument
104 down_write(&tty->termios_rwsem); in tty_throttle()
106 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && in tty_throttle()
107 tty->ops->throttle) in tty_throttle()
108 tty->ops->throttle(tty); in tty_throttle()
109 tty->flow_change = 0; in tty_throttle()
110 up_write(&tty->termios_rwsem); in tty_throttle()
127 void tty_unthrottle(struct tty_struct *tty) in tty_unthrottle() argument
129 down_write(&tty->termios_rwsem); in tty_unthrottle()
130 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && in tty_unthrottle()
131 tty->ops->unthrottle) in tty_unthrottle()
132 tty->ops->unthrottle(tty); in tty_unthrottle()
133 tty->flow_change = 0; in tty_unthrottle()
134 up_write(&tty->termios_rwsem); in tty_unthrottle()
150 int tty_throttle_safe(struct tty_struct *tty) in tty_throttle_safe() argument
154 mutex_lock(&tty->throttle_mutex); in tty_throttle_safe()
155 if (!test_bit(TTY_THROTTLED, &tty->flags)) { in tty_throttle_safe()
156 if (tty->flow_change != TTY_THROTTLE_SAFE) in tty_throttle_safe()
159 set_bit(TTY_THROTTLED, &tty->flags); in tty_throttle_safe()
160 if (tty->ops->throttle) in tty_throttle_safe()
161 tty->ops->throttle(tty); in tty_throttle_safe()
164 mutex_unlock(&tty->throttle_mutex); in tty_throttle_safe()
181 int tty_unthrottle_safe(struct tty_struct *tty) in tty_unthrottle_safe() argument
185 mutex_lock(&tty->throttle_mutex); in tty_unthrottle_safe()
186 if (test_bit(TTY_THROTTLED, &tty->flags)) { in tty_unthrottle_safe()
187 if (tty->flow_change != TTY_UNTHROTTLE_SAFE) in tty_unthrottle_safe()
190 clear_bit(TTY_THROTTLED, &tty->flags); in tty_unthrottle_safe()
191 if (tty->ops->unthrottle) in tty_unthrottle_safe()
192 tty->ops->unthrottle(tty); in tty_unthrottle_safe()
195 mutex_unlock(&tty->throttle_mutex); in tty_unthrottle_safe()
211 void tty_wait_until_sent(struct tty_struct *tty, long timeout) in tty_wait_until_sent() argument
216 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); in tty_wait_until_sent()
221 timeout = wait_event_interruptible_timeout(tty->write_wait, in tty_wait_until_sent()
222 !tty_chars_in_buffer(tty), timeout); in tty_wait_until_sent()
229 if (tty->ops->wait_until_sent) in tty_wait_until_sent()
230 tty->ops->wait_until_sent(tty, timeout); in tty_wait_until_sent()
481 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud) in tty_encode_baud_rate() argument
483 tty_termios_encode_baud_rate(&tty->termios, ibaud, obaud); in tty_encode_baud_rate()
539 int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) in tty_set_termios() argument
544 WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY && in tty_set_termios()
545 tty->driver->subtype == PTY_TYPE_MASTER); in tty_set_termios()
553 down_write(&tty->termios_rwsem); in tty_set_termios()
554 old_termios = tty->termios; in tty_set_termios()
555 tty->termios = *new_termios; in tty_set_termios()
556 unset_locked_termios(&tty->termios, &old_termios, &tty->termios_locked); in tty_set_termios()
558 if (tty->ops->set_termios) in tty_set_termios()
559 tty->ops->set_termios(tty, &old_termios); in tty_set_termios()
561 tty_termios_copy_hw(&tty->termios, &old_termios); in tty_set_termios()
563 ld = tty_ldisc_ref(tty); in tty_set_termios()
566 ld->ops->set_termios(tty, &old_termios); in tty_set_termios()
569 up_write(&tty->termios_rwsem); in tty_set_termios()
587 static int set_termios(struct tty_struct *tty, void __user *arg, int opt) in set_termios() argument
591 int retval = tty_check_change(tty); in set_termios()
596 down_read(&tty->termios_rwsem); in set_termios()
597 tmp_termios = tty->termios; in set_termios()
598 up_read(&tty->termios_rwsem); in set_termios()
625 ld = tty_ldisc_ref(tty);
629 ld->ops->flush_buffer(tty);
634 tty_wait_until_sent(tty, 0);
639 tty_set_termios(tty, &tmp_termios);
648 static void copy_termios(struct tty_struct *tty, struct ktermios *kterm) in copy_termios() argument
650 down_read(&tty->termios_rwsem); in copy_termios()
651 *kterm = tty->termios; in copy_termios()
652 up_read(&tty->termios_rwsem); in copy_termios()
655 static void copy_termios_locked(struct tty_struct *tty, struct ktermios *kterm) in copy_termios_locked() argument
657 down_read(&tty->termios_rwsem); in copy_termios_locked()
658 *kterm = tty->termios_locked; in copy_termios_locked()
659 up_read(&tty->termios_rwsem); in copy_termios_locked()
662 static int get_termio(struct tty_struct *tty, struct termio __user *termio) in get_termio() argument
665 copy_termios(tty, &kterm); in get_termio()
684 static int set_termiox(struct tty_struct *tty, void __user *arg, int opt) in set_termiox() argument
689 if (tty->termiox == NULL) in set_termiox()
694 ld = tty_ldisc_ref(tty); in set_termiox()
697 ld->ops->flush_buffer(tty); in set_termiox()
701 tty_wait_until_sent(tty, 0); in set_termiox()
706 down_write(&tty->termios_rwsem); in set_termiox()
707 if (tty->ops->set_termiox) in set_termiox()
708 tty->ops->set_termiox(tty, &tnew); in set_termiox()
709 up_write(&tty->termios_rwsem); in set_termiox()
722 static int get_sgflags(struct tty_struct *tty) in get_sgflags() argument
726 if (!(tty->termios.c_lflag & ICANON)) { in get_sgflags()
727 if (tty->termios.c_lflag & ISIG) in get_sgflags()
732 if (tty->termios.c_lflag & ECHO) in get_sgflags()
734 if (tty->termios.c_oflag & OPOST) in get_sgflags()
735 if (tty->termios.c_oflag & ONLCR) in get_sgflags()
740 static int get_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in get_sgttyb() argument
744 down_read(&tty->termios_rwsem); in get_sgttyb()
745 tmp.sg_ispeed = tty->termios.c_ispeed; in get_sgttyb()
746 tmp.sg_ospeed = tty->termios.c_ospeed; in get_sgttyb()
747 tmp.sg_erase = tty->termios.c_cc[VERASE]; in get_sgttyb()
748 tmp.sg_kill = tty->termios.c_cc[VKILL]; in get_sgttyb()
749 tmp.sg_flags = get_sgflags(tty); in get_sgttyb()
750 up_read(&tty->termios_rwsem); in get_sgttyb()
792 static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in set_sgttyb() argument
798 retval = tty_check_change(tty); in set_sgttyb()
805 down_write(&tty->termios_rwsem); in set_sgttyb()
806 termios = tty->termios; in set_sgttyb()
815 up_write(&tty->termios_rwsem); in set_sgttyb()
816 tty_set_termios(tty, &termios); in set_sgttyb()
822 static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars) in get_tchars() argument
826 down_read(&tty->termios_rwsem); in get_tchars()
827 tmp.t_intrc = tty->termios.c_cc[VINTR]; in get_tchars()
828 tmp.t_quitc = tty->termios.c_cc[VQUIT]; in get_tchars()
829 tmp.t_startc = tty->termios.c_cc[VSTART]; in get_tchars()
830 tmp.t_stopc = tty->termios.c_cc[VSTOP]; in get_tchars()
831 tmp.t_eofc = tty->termios.c_cc[VEOF]; in get_tchars()
832 tmp.t_brkc = tty->termios.c_cc[VEOL2]; /* what is brkc anyway? */ in get_tchars()
833 up_read(&tty->termios_rwsem); in get_tchars()
837 static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars) in set_tchars() argument
843 down_write(&tty->termios_rwsem); in set_tchars()
844 tty->termios.c_cc[VINTR] = tmp.t_intrc; in set_tchars()
845 tty->termios.c_cc[VQUIT] = tmp.t_quitc; in set_tchars()
846 tty->termios.c_cc[VSTART] = tmp.t_startc; in set_tchars()
847 tty->termios.c_cc[VSTOP] = tmp.t_stopc; in set_tchars()
848 tty->termios.c_cc[VEOF] = tmp.t_eofc; in set_tchars()
849 tty->termios.c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ in set_tchars()
850 up_write(&tty->termios_rwsem); in set_tchars()
856 static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in get_ltchars() argument
860 down_read(&tty->termios_rwsem); in get_ltchars()
861 tmp.t_suspc = tty->termios.c_cc[VSUSP]; in get_ltchars()
863 tmp.t_dsuspc = tty->termios.c_cc[VSUSP]; in get_ltchars()
864 tmp.t_rprntc = tty->termios.c_cc[VREPRINT]; in get_ltchars()
866 tmp.t_flushc = tty->termios.c_cc[VEOL2]; in get_ltchars()
867 tmp.t_werasc = tty->termios.c_cc[VWERASE]; in get_ltchars()
868 tmp.t_lnextc = tty->termios.c_cc[VLNEXT]; in get_ltchars()
869 up_read(&tty->termios_rwsem); in get_ltchars()
873 static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in set_ltchars() argument
880 down_write(&tty->termios_rwsem); in set_ltchars()
881 tty->termios.c_cc[VSUSP] = tmp.t_suspc; in set_ltchars()
883 tty->termios.c_cc[VEOL2] = tmp.t_dsuspc; in set_ltchars()
884 tty->termios.c_cc[VREPRINT] = tmp.t_rprntc; in set_ltchars()
886 tty->termios.c_cc[VEOL2] = tmp.t_flushc; in set_ltchars()
887 tty->termios.c_cc[VWERASE] = tmp.t_werasc; in set_ltchars()
888 tty->termios.c_cc[VLNEXT] = tmp.t_lnextc; in set_ltchars()
889 up_write(&tty->termios_rwsem); in set_ltchars()
903 static int tty_change_softcar(struct tty_struct *tty, int arg) in tty_change_softcar() argument
909 down_write(&tty->termios_rwsem); in tty_change_softcar()
910 old = tty->termios; in tty_change_softcar()
911 tty->termios.c_cflag &= ~CLOCAL; in tty_change_softcar()
912 tty->termios.c_cflag |= bit; in tty_change_softcar()
913 if (tty->ops->set_termios) in tty_change_softcar()
914 tty->ops->set_termios(tty, &old); in tty_change_softcar()
915 if ((tty->termios.c_cflag & CLOCAL) != bit) in tty_change_softcar()
917 up_write(&tty->termios_rwsem); in tty_change_softcar()
933 int tty_mode_ioctl(struct tty_struct *tty, struct file *file, in tty_mode_ioctl() argument
943 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && in tty_mode_ioctl()
944 tty->driver->subtype == PTY_TYPE_MASTER) in tty_mode_ioctl()
945 real_tty = tty->link; in tty_mode_ioctl()
947 real_tty = tty; in tty_mode_ioctl()
1078 static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) in __tty_perform_flush() argument
1080 struct tty_ldisc *ld = tty->ldisc; in __tty_perform_flush()
1085 ld->ops->flush_buffer(tty); in __tty_perform_flush()
1086 tty_unthrottle(tty); in __tty_perform_flush()
1091 ld->ops->flush_buffer(tty); in __tty_perform_flush()
1092 tty_unthrottle(tty); in __tty_perform_flush()
1096 tty_driver_flush_buffer(tty); in __tty_perform_flush()
1104 int tty_perform_flush(struct tty_struct *tty, unsigned long arg) in tty_perform_flush() argument
1107 int retval = tty_check_change(tty); in tty_perform_flush()
1111 ld = tty_ldisc_ref_wait(tty); in tty_perform_flush()
1112 retval = __tty_perform_flush(tty, arg); in tty_perform_flush()
1119 int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, in n_tty_ioctl_helper() argument
1126 retval = tty_check_change(tty); in n_tty_ioctl_helper()
1131 spin_lock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
1132 if (!tty->flow_stopped) { in n_tty_ioctl_helper()
1133 tty->flow_stopped = 1; in n_tty_ioctl_helper()
1134 __stop_tty(tty); in n_tty_ioctl_helper()
1136 spin_unlock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
1139 spin_lock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
1140 if (tty->flow_stopped) { in n_tty_ioctl_helper()
1141 tty->flow_stopped = 0; in n_tty_ioctl_helper()
1142 __start_tty(tty); in n_tty_ioctl_helper()
1144 spin_unlock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
1147 if (STOP_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
1148 retval = tty_send_xchar(tty, STOP_CHAR(tty)); in n_tty_ioctl_helper()
1151 if (START_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
1152 retval = tty_send_xchar(tty, START_CHAR(tty)); in n_tty_ioctl_helper()
1159 retval = tty_check_change(tty); in n_tty_ioctl_helper()
1162 return __tty_perform_flush(tty, arg); in n_tty_ioctl_helper()
1165 return tty_mode_ioctl(tty, file, cmd, arg); in n_tty_ioctl_helper()
1171 long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, in n_tty_compat_ioctl_helper() argument
1177 return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg)); in n_tty_compat_ioctl_helper()