Lines Matching refs:tty
52 int tty_chars_in_buffer(struct tty_struct *tty) in tty_chars_in_buffer() argument
54 if (tty->ops->chars_in_buffer) in tty_chars_in_buffer()
55 return tty->ops->chars_in_buffer(tty); in tty_chars_in_buffer()
72 int tty_write_room(struct tty_struct *tty) in tty_write_room() argument
74 if (tty->ops->write_room) in tty_write_room()
75 return tty->ops->write_room(tty); in tty_write_room()
88 void tty_driver_flush_buffer(struct tty_struct *tty) in tty_driver_flush_buffer() argument
90 if (tty->ops->flush_buffer) in tty_driver_flush_buffer()
91 tty->ops->flush_buffer(tty); in tty_driver_flush_buffer()
102 void tty_throttle(struct tty_struct *tty) in tty_throttle() argument
105 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && in tty_throttle()
106 tty->ops->throttle) in tty_throttle()
107 tty->ops->throttle(tty); in tty_throttle()
118 void tty_unthrottle(struct tty_struct *tty) in tty_unthrottle() argument
120 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && in tty_unthrottle()
121 tty->ops->unthrottle) in tty_unthrottle()
122 tty->ops->unthrottle(tty); in tty_unthrottle()
137 void tty_wait_until_sent(struct tty_struct *tty, long timeout) in tty_wait_until_sent() argument
142 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); in tty_wait_until_sent()
146 if (wait_event_interruptible_timeout(tty->write_wait, in tty_wait_until_sent()
147 !tty_chars_in_buffer(tty), timeout) >= 0) { in tty_wait_until_sent()
148 if (tty->ops->wait_until_sent) in tty_wait_until_sent()
149 tty->ops->wait_until_sent(tty, timeout); in tty_wait_until_sent()
403 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud) in tty_encode_baud_rate() argument
405 tty_termios_encode_baud_rate(tty->termios, ibaud, obaud); in tty_encode_baud_rate()
420 speed_t tty_get_baud_rate(struct tty_struct *tty) in tty_get_baud_rate() argument
422 speed_t baud = tty_termios_baud_rate(tty->termios); in tty_get_baud_rate()
424 if (baud == 38400 && tty->alt_speed) { in tty_get_baud_rate()
425 if (!tty->warned) { in tty_get_baud_rate()
428 tty->warned = 1; in tty_get_baud_rate()
430 baud = tty->alt_speed; in tty_get_baud_rate()
490 static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) in change_termios() argument
503 mutex_lock(&tty->termios_mutex); in change_termios()
504 old_termios = *tty->termios; in change_termios()
505 *tty->termios = *new_termios; in change_termios()
506 unset_locked_termios(tty->termios, &old_termios, tty->termios_locked); in change_termios()
509 if (tty->link && tty->link->packet) { in change_termios()
513 int new_flow = (I_IXON(tty) && in change_termios()
514 STOP_CHAR(tty) == '\023' && in change_termios()
515 START_CHAR(tty) == '\021'); in change_termios()
517 spin_lock_irqsave(&tty->ctrl_lock, flags); in change_termios()
518 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); in change_termios()
520 tty->ctrl_status |= TIOCPKT_DOSTOP; in change_termios()
522 tty->ctrl_status |= TIOCPKT_NOSTOP; in change_termios()
523 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in change_termios()
524 wake_up_interruptible(&tty->link->read_wait); in change_termios()
528 if (tty->ops->set_termios) in change_termios()
529 (*tty->ops->set_termios)(tty, &old_termios); in change_termios()
531 tty_termios_copy_hw(tty->termios, &old_termios); in change_termios()
533 ld = tty_ldisc_ref(tty); in change_termios()
536 (ld->ops->set_termios)(tty, &old_termios); in change_termios()
539 mutex_unlock(&tty->termios_mutex); in change_termios()
555 static int set_termios(struct tty_struct *tty, void __user *arg, int opt) in set_termios() argument
559 int retval = tty_check_change(tty); in set_termios()
564 mutex_lock(&tty->termios_mutex); in set_termios()
565 memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios)); in set_termios()
566 mutex_unlock(&tty->termios_mutex); in set_termios()
593 ld = tty_ldisc_ref(tty);
597 ld->ops->flush_buffer(tty);
602 tty_wait_until_sent(tty, 0);
607 change_termios(tty, &tmp_termios);
616 static int get_termio(struct tty_struct *tty, struct termio __user *termio) in get_termio() argument
618 if (kernel_termios_to_user_termio(termio, tty->termios)) in get_termio()
636 static int set_termiox(struct tty_struct *tty, void __user *arg, int opt) in set_termiox() argument
641 if (tty->termiox == NULL) in set_termiox()
646 ld = tty_ldisc_ref(tty); in set_termiox()
649 ld->ops->flush_buffer(tty); in set_termiox()
653 tty_wait_until_sent(tty, 0); in set_termiox()
658 mutex_lock(&tty->termios_mutex); in set_termiox()
659 if (tty->ops->set_termiox) in set_termiox()
660 tty->ops->set_termiox(tty, &tnew); in set_termiox()
661 mutex_unlock(&tty->termios_mutex); in set_termiox()
674 static int get_sgflags(struct tty_struct *tty) in get_sgflags() argument
678 if (!(tty->termios->c_lflag & ICANON)) { in get_sgflags()
679 if (tty->termios->c_lflag & ISIG) in get_sgflags()
684 if (tty->termios->c_lflag & ECHO) in get_sgflags()
686 if (tty->termios->c_oflag & OPOST) in get_sgflags()
687 if (tty->termios->c_oflag & ONLCR) in get_sgflags()
692 static int get_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in get_sgttyb() argument
696 mutex_lock(&tty->termios_mutex); in get_sgttyb()
697 tmp.sg_ispeed = tty->termios->c_ispeed; in get_sgttyb()
698 tmp.sg_ospeed = tty->termios->c_ospeed; in get_sgttyb()
699 tmp.sg_erase = tty->termios->c_cc[VERASE]; in get_sgttyb()
700 tmp.sg_kill = tty->termios->c_cc[VKILL]; in get_sgttyb()
701 tmp.sg_flags = get_sgflags(tty); in get_sgttyb()
702 mutex_unlock(&tty->termios_mutex); in get_sgttyb()
744 static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in set_sgttyb() argument
750 retval = tty_check_change(tty); in set_sgttyb()
757 mutex_lock(&tty->termios_mutex); in set_sgttyb()
758 termios = *tty->termios; in set_sgttyb()
767 mutex_unlock(&tty->termios_mutex); in set_sgttyb()
768 change_termios(tty, &termios); in set_sgttyb()
774 static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars) in get_tchars() argument
778 mutex_lock(&tty->termios_mutex); in get_tchars()
779 tmp.t_intrc = tty->termios->c_cc[VINTR]; in get_tchars()
780 tmp.t_quitc = tty->termios->c_cc[VQUIT]; in get_tchars()
781 tmp.t_startc = tty->termios->c_cc[VSTART]; in get_tchars()
782 tmp.t_stopc = tty->termios->c_cc[VSTOP]; in get_tchars()
783 tmp.t_eofc = tty->termios->c_cc[VEOF]; in get_tchars()
784 tmp.t_brkc = tty->termios->c_cc[VEOL2]; /* what is brkc anyway? */ in get_tchars()
785 mutex_unlock(&tty->termios_mutex); in get_tchars()
789 static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars) in set_tchars() argument
795 mutex_lock(&tty->termios_mutex); in set_tchars()
796 tty->termios->c_cc[VINTR] = tmp.t_intrc; in set_tchars()
797 tty->termios->c_cc[VQUIT] = tmp.t_quitc; in set_tchars()
798 tty->termios->c_cc[VSTART] = tmp.t_startc; in set_tchars()
799 tty->termios->c_cc[VSTOP] = tmp.t_stopc; in set_tchars()
800 tty->termios->c_cc[VEOF] = tmp.t_eofc; in set_tchars()
801 tty->termios->c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ in set_tchars()
802 mutex_unlock(&tty->termios_mutex); in set_tchars()
808 static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in get_ltchars() argument
812 mutex_lock(&tty->termios_mutex); in get_ltchars()
813 tmp.t_suspc = tty->termios->c_cc[VSUSP]; in get_ltchars()
815 tmp.t_dsuspc = tty->termios->c_cc[VSUSP]; in get_ltchars()
816 tmp.t_rprntc = tty->termios->c_cc[VREPRINT]; in get_ltchars()
818 tmp.t_flushc = tty->termios->c_cc[VEOL2]; in get_ltchars()
819 tmp.t_werasc = tty->termios->c_cc[VWERASE]; in get_ltchars()
820 tmp.t_lnextc = tty->termios->c_cc[VLNEXT]; in get_ltchars()
821 mutex_unlock(&tty->termios_mutex); in get_ltchars()
825 static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in set_ltchars() argument
832 mutex_lock(&tty->termios_mutex); in set_ltchars()
833 tty->termios->c_cc[VSUSP] = tmp.t_suspc; in set_ltchars()
835 tty->termios->c_cc[VEOL2] = tmp.t_dsuspc; in set_ltchars()
836 tty->termios->c_cc[VREPRINT] = tmp.t_rprntc; in set_ltchars()
838 tty->termios->c_cc[VEOL2] = tmp.t_flushc; in set_ltchars()
839 tty->termios->c_cc[VWERASE] = tmp.t_werasc; in set_ltchars()
840 tty->termios->c_cc[VLNEXT] = tmp.t_lnextc; in set_ltchars()
841 mutex_unlock(&tty->termios_mutex); in set_ltchars()
854 static int send_prio_char(struct tty_struct *tty, char ch) in send_prio_char() argument
856 int was_stopped = tty->stopped; in send_prio_char()
858 if (tty->ops->send_xchar) { in send_prio_char()
859 tty->ops->send_xchar(tty, ch); in send_prio_char()
863 if (tty_write_lock(tty, 0) < 0) in send_prio_char()
867 start_tty(tty); in send_prio_char()
868 tty->ops->write(tty, &ch, 1); in send_prio_char()
870 stop_tty(tty); in send_prio_char()
871 tty_write_unlock(tty); in send_prio_char()
884 static int tty_change_softcar(struct tty_struct *tty, int arg) in tty_change_softcar() argument
890 mutex_lock(&tty->termios_mutex); in tty_change_softcar()
891 old = *tty->termios; in tty_change_softcar()
892 tty->termios->c_cflag &= ~CLOCAL; in tty_change_softcar()
893 tty->termios->c_cflag |= bit; in tty_change_softcar()
894 if (tty->ops->set_termios) in tty_change_softcar()
895 tty->ops->set_termios(tty, &old); in tty_change_softcar()
896 if ((tty->termios->c_cflag & CLOCAL) != bit) in tty_change_softcar()
898 mutex_unlock(&tty->termios_mutex); in tty_change_softcar()
914 int tty_mode_ioctl(struct tty_struct *tty, struct file *file, in tty_mode_ioctl() argument
921 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && in tty_mode_ioctl()
922 tty->driver->subtype == PTY_TYPE_MASTER) in tty_mode_ioctl()
923 real_tty = tty->link; in tty_mode_ioctl()
925 real_tty = tty; in tty_mode_ioctl()
1053 int tty_perform_flush(struct tty_struct *tty, unsigned long arg) in tty_perform_flush() argument
1056 int retval = tty_check_change(tty); in tty_perform_flush()
1060 ld = tty_ldisc_ref_wait(tty); in tty_perform_flush()
1064 ld->ops->flush_buffer(tty); in tty_perform_flush()
1068 ld->ops->flush_buffer(tty); in tty_perform_flush()
1071 tty_driver_flush_buffer(tty); in tty_perform_flush()
1082 int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, in n_tty_ioctl_helper() argument
1090 retval = tty_check_change(tty); in n_tty_ioctl_helper()
1095 if (!tty->flow_stopped) { in n_tty_ioctl_helper()
1096 tty->flow_stopped = 1; in n_tty_ioctl_helper()
1097 stop_tty(tty); in n_tty_ioctl_helper()
1101 if (tty->flow_stopped) { in n_tty_ioctl_helper()
1102 tty->flow_stopped = 0; in n_tty_ioctl_helper()
1103 start_tty(tty); in n_tty_ioctl_helper()
1107 if (STOP_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
1108 return send_prio_char(tty, STOP_CHAR(tty)); in n_tty_ioctl_helper()
1111 if (START_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
1112 return send_prio_char(tty, START_CHAR(tty)); in n_tty_ioctl_helper()
1119 return tty_perform_flush(tty, arg); in n_tty_ioctl_helper()
1124 if (tty->driver->type != TTY_DRIVER_TYPE_PTY || in n_tty_ioctl_helper()
1125 tty->driver->subtype != PTY_TYPE_MASTER) in n_tty_ioctl_helper()
1129 spin_lock_irqsave(&tty->ctrl_lock, flags); in n_tty_ioctl_helper()
1131 if (!tty->packet) { in n_tty_ioctl_helper()
1132 tty->packet = 1; in n_tty_ioctl_helper()
1133 tty->link->ctrl_status = 0; in n_tty_ioctl_helper()
1136 tty->packet = 0; in n_tty_ioctl_helper()
1137 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in n_tty_ioctl_helper()
1142 return tty_mode_ioctl(tty, file, cmd, arg); in n_tty_ioctl_helper()