• Home
  • Raw
  • Download

Lines Matching refs:tty

31 # define tty_debug_wait_until_sent(tty, f, args...)    tty_debug(tty, f, ##args)  argument
33 # define tty_debug_wait_until_sent(tty, f, args...) do {} while (0) argument
56 int tty_chars_in_buffer(struct tty_struct *tty) in tty_chars_in_buffer() argument
58 if (tty->ops->chars_in_buffer) in tty_chars_in_buffer()
59 return tty->ops->chars_in_buffer(tty); in tty_chars_in_buffer()
76 int tty_write_room(struct tty_struct *tty) in tty_write_room() argument
78 if (tty->ops->write_room) in tty_write_room()
79 return tty->ops->write_room(tty); in tty_write_room()
92 void tty_driver_flush_buffer(struct tty_struct *tty) in tty_driver_flush_buffer() argument
94 if (tty->ops->flush_buffer) in tty_driver_flush_buffer()
95 tty->ops->flush_buffer(tty); in tty_driver_flush_buffer()
109 void tty_throttle(struct tty_struct *tty) in tty_throttle() argument
111 down_write(&tty->termios_rwsem); in tty_throttle()
113 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && in tty_throttle()
114 tty->ops->throttle) in tty_throttle()
115 tty->ops->throttle(tty); in tty_throttle()
116 tty->flow_change = 0; in tty_throttle()
117 up_write(&tty->termios_rwsem); in tty_throttle()
134 void tty_unthrottle(struct tty_struct *tty) in tty_unthrottle() argument
136 down_write(&tty->termios_rwsem); in tty_unthrottle()
137 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && in tty_unthrottle()
138 tty->ops->unthrottle) in tty_unthrottle()
139 tty->ops->unthrottle(tty); in tty_unthrottle()
140 tty->flow_change = 0; in tty_unthrottle()
141 up_write(&tty->termios_rwsem); in tty_unthrottle()
157 int tty_throttle_safe(struct tty_struct *tty) in tty_throttle_safe() argument
161 mutex_lock(&tty->throttle_mutex); in tty_throttle_safe()
162 if (!tty_throttled(tty)) { in tty_throttle_safe()
163 if (tty->flow_change != TTY_THROTTLE_SAFE) in tty_throttle_safe()
166 set_bit(TTY_THROTTLED, &tty->flags); in tty_throttle_safe()
167 if (tty->ops->throttle) in tty_throttle_safe()
168 tty->ops->throttle(tty); in tty_throttle_safe()
171 mutex_unlock(&tty->throttle_mutex); in tty_throttle_safe()
188 int tty_unthrottle_safe(struct tty_struct *tty) in tty_unthrottle_safe() argument
192 mutex_lock(&tty->throttle_mutex); in tty_unthrottle_safe()
193 if (tty_throttled(tty)) { in tty_unthrottle_safe()
194 if (tty->flow_change != TTY_UNTHROTTLE_SAFE) in tty_unthrottle_safe()
197 clear_bit(TTY_THROTTLED, &tty->flags); in tty_unthrottle_safe()
198 if (tty->ops->unthrottle) in tty_unthrottle_safe()
199 tty->ops->unthrottle(tty); in tty_unthrottle_safe()
202 mutex_unlock(&tty->throttle_mutex); in tty_unthrottle_safe()
218 void tty_wait_until_sent(struct tty_struct *tty, long timeout) in tty_wait_until_sent() argument
220 tty_debug_wait_until_sent(tty, "wait until sent, timeout=%ld\n", timeout); in tty_wait_until_sent()
225 timeout = wait_event_interruptible_timeout(tty->write_wait, in tty_wait_until_sent()
226 !tty_chars_in_buffer(tty), timeout); in tty_wait_until_sent()
233 if (tty->ops->wait_until_sent) in tty_wait_until_sent()
234 tty->ops->wait_until_sent(tty, timeout); in tty_wait_until_sent()
243 static void unset_locked_termios(struct tty_struct *tty, struct ktermios *old) in unset_locked_termios() argument
245 struct ktermios *termios = &tty->termios; in unset_locked_termios()
246 struct ktermios *locked = &tty->termios_locked; in unset_locked_termios()
314 int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) in tty_set_termios() argument
319 WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY && in tty_set_termios()
320 tty->driver->subtype == PTY_TYPE_MASTER); in tty_set_termios()
328 down_write(&tty->termios_rwsem); in tty_set_termios()
329 old_termios = tty->termios; in tty_set_termios()
330 tty->termios = *new_termios; in tty_set_termios()
331 unset_locked_termios(tty, &old_termios); in tty_set_termios()
333 if (tty->ops->set_termios) in tty_set_termios()
334 tty->ops->set_termios(tty, &old_termios); in tty_set_termios()
336 tty_termios_copy_hw(&tty->termios, &old_termios); in tty_set_termios()
338 ld = tty_ldisc_ref(tty); in tty_set_termios()
341 ld->ops->set_termios(tty, &old_termios); in tty_set_termios()
344 up_write(&tty->termios_rwsem); in tty_set_termios()
362 static int set_termios(struct tty_struct *tty, void __user *arg, int opt) in set_termios() argument
366 int retval = tty_check_change(tty); in set_termios()
371 down_read(&tty->termios_rwsem); in set_termios()
372 tmp_termios = tty->termios; in set_termios()
373 up_read(&tty->termios_rwsem); in set_termios()
400 ld = tty_ldisc_ref(tty);
404 ld->ops->flush_buffer(tty);
409 tty_wait_until_sent(tty, 0);
414 tty_set_termios(tty, &tmp_termios);
423 static void copy_termios(struct tty_struct *tty, struct ktermios *kterm) in copy_termios() argument
425 down_read(&tty->termios_rwsem); in copy_termios()
426 *kterm = tty->termios; in copy_termios()
427 up_read(&tty->termios_rwsem); in copy_termios()
430 static void copy_termios_locked(struct tty_struct *tty, struct ktermios *kterm) in copy_termios_locked() argument
432 down_read(&tty->termios_rwsem); in copy_termios_locked()
433 *kterm = tty->termios_locked; in copy_termios_locked()
434 up_read(&tty->termios_rwsem); in copy_termios_locked()
437 static int get_termio(struct tty_struct *tty, struct termio __user *termio) in get_termio() argument
440 copy_termios(tty, &kterm); in get_termio()
452 static int get_sgflags(struct tty_struct *tty) in get_sgflags() argument
456 if (!L_ICANON(tty)) { in get_sgflags()
457 if (L_ISIG(tty)) in get_sgflags()
462 if (L_ECHO(tty)) in get_sgflags()
464 if (O_OPOST(tty)) in get_sgflags()
465 if (O_ONLCR(tty)) in get_sgflags()
470 static int get_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in get_sgttyb() argument
474 down_read(&tty->termios_rwsem); in get_sgttyb()
475 tmp.sg_ispeed = tty->termios.c_ispeed; in get_sgttyb()
476 tmp.sg_ospeed = tty->termios.c_ospeed; in get_sgttyb()
477 tmp.sg_erase = tty->termios.c_cc[VERASE]; in get_sgttyb()
478 tmp.sg_kill = tty->termios.c_cc[VKILL]; in get_sgttyb()
479 tmp.sg_flags = get_sgflags(tty); in get_sgttyb()
480 up_read(&tty->termios_rwsem); in get_sgttyb()
522 static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) in set_sgttyb() argument
528 retval = tty_check_change(tty); in set_sgttyb()
535 down_write(&tty->termios_rwsem); in set_sgttyb()
536 termios = tty->termios; in set_sgttyb()
545 up_write(&tty->termios_rwsem); in set_sgttyb()
546 tty_set_termios(tty, &termios); in set_sgttyb()
552 static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars) in get_tchars() argument
556 down_read(&tty->termios_rwsem); in get_tchars()
557 tmp.t_intrc = tty->termios.c_cc[VINTR]; in get_tchars()
558 tmp.t_quitc = tty->termios.c_cc[VQUIT]; in get_tchars()
559 tmp.t_startc = tty->termios.c_cc[VSTART]; in get_tchars()
560 tmp.t_stopc = tty->termios.c_cc[VSTOP]; in get_tchars()
561 tmp.t_eofc = tty->termios.c_cc[VEOF]; in get_tchars()
562 tmp.t_brkc = tty->termios.c_cc[VEOL2]; /* what is brkc anyway? */ in get_tchars()
563 up_read(&tty->termios_rwsem); in get_tchars()
567 static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars) in set_tchars() argument
573 down_write(&tty->termios_rwsem); in set_tchars()
574 tty->termios.c_cc[VINTR] = tmp.t_intrc; in set_tchars()
575 tty->termios.c_cc[VQUIT] = tmp.t_quitc; in set_tchars()
576 tty->termios.c_cc[VSTART] = tmp.t_startc; in set_tchars()
577 tty->termios.c_cc[VSTOP] = tmp.t_stopc; in set_tchars()
578 tty->termios.c_cc[VEOF] = tmp.t_eofc; in set_tchars()
579 tty->termios.c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ in set_tchars()
580 up_write(&tty->termios_rwsem); in set_tchars()
586 static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in get_ltchars() argument
590 down_read(&tty->termios_rwsem); in get_ltchars()
591 tmp.t_suspc = tty->termios.c_cc[VSUSP]; in get_ltchars()
593 tmp.t_dsuspc = tty->termios.c_cc[VSUSP]; in get_ltchars()
594 tmp.t_rprntc = tty->termios.c_cc[VREPRINT]; in get_ltchars()
596 tmp.t_flushc = tty->termios.c_cc[VEOL2]; in get_ltchars()
597 tmp.t_werasc = tty->termios.c_cc[VWERASE]; in get_ltchars()
598 tmp.t_lnextc = tty->termios.c_cc[VLNEXT]; in get_ltchars()
599 up_read(&tty->termios_rwsem); in get_ltchars()
603 static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) in set_ltchars() argument
610 down_write(&tty->termios_rwsem); in set_ltchars()
611 tty->termios.c_cc[VSUSP] = tmp.t_suspc; in set_ltchars()
613 tty->termios.c_cc[VEOL2] = tmp.t_dsuspc; in set_ltchars()
614 tty->termios.c_cc[VREPRINT] = tmp.t_rprntc; in set_ltchars()
616 tty->termios.c_cc[VEOL2] = tmp.t_flushc; in set_ltchars()
617 tty->termios.c_cc[VWERASE] = tmp.t_werasc; in set_ltchars()
618 tty->termios.c_cc[VLNEXT] = tmp.t_lnextc; in set_ltchars()
619 up_write(&tty->termios_rwsem); in set_ltchars()
633 static int tty_change_softcar(struct tty_struct *tty, int arg) in tty_change_softcar() argument
639 down_write(&tty->termios_rwsem); in tty_change_softcar()
640 old = tty->termios; in tty_change_softcar()
641 tty->termios.c_cflag &= ~CLOCAL; in tty_change_softcar()
642 tty->termios.c_cflag |= bit; in tty_change_softcar()
643 if (tty->ops->set_termios) in tty_change_softcar()
644 tty->ops->set_termios(tty, &old); in tty_change_softcar()
645 if (C_CLOCAL(tty) != bit) in tty_change_softcar()
647 up_write(&tty->termios_rwsem); in tty_change_softcar()
663 int tty_mode_ioctl(struct tty_struct *tty, struct file *file, in tty_mode_ioctl() argument
673 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && in tty_mode_ioctl()
674 tty->driver->subtype == PTY_TYPE_MASTER) in tty_mode_ioctl()
675 real_tty = tty->link; in tty_mode_ioctl()
677 real_tty = tty; in tty_mode_ioctl()
796 static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) in __tty_perform_flush() argument
798 struct tty_ldisc *ld = tty->ldisc; in __tty_perform_flush()
803 ld->ops->flush_buffer(tty); in __tty_perform_flush()
804 tty_unthrottle(tty); in __tty_perform_flush()
809 ld->ops->flush_buffer(tty); in __tty_perform_flush()
810 tty_unthrottle(tty); in __tty_perform_flush()
814 tty_driver_flush_buffer(tty); in __tty_perform_flush()
822 int tty_perform_flush(struct tty_struct *tty, unsigned long arg) in tty_perform_flush() argument
825 int retval = tty_check_change(tty); in tty_perform_flush()
829 ld = tty_ldisc_ref_wait(tty); in tty_perform_flush()
830 retval = __tty_perform_flush(tty, arg); in tty_perform_flush()
837 int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, in n_tty_ioctl_helper() argument
844 retval = tty_check_change(tty); in n_tty_ioctl_helper()
849 spin_lock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
850 if (!tty->flow_stopped) { in n_tty_ioctl_helper()
851 tty->flow_stopped = 1; in n_tty_ioctl_helper()
852 __stop_tty(tty); in n_tty_ioctl_helper()
854 spin_unlock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
857 spin_lock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
858 if (tty->flow_stopped) { in n_tty_ioctl_helper()
859 tty->flow_stopped = 0; in n_tty_ioctl_helper()
860 __start_tty(tty); in n_tty_ioctl_helper()
862 spin_unlock_irq(&tty->flow_lock); in n_tty_ioctl_helper()
865 if (STOP_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
866 retval = tty_send_xchar(tty, STOP_CHAR(tty)); in n_tty_ioctl_helper()
869 if (START_CHAR(tty) != __DISABLED_CHAR) in n_tty_ioctl_helper()
870 retval = tty_send_xchar(tty, START_CHAR(tty)); in n_tty_ioctl_helper()
877 retval = tty_check_change(tty); in n_tty_ioctl_helper()
880 return __tty_perform_flush(tty, arg); in n_tty_ioctl_helper()
883 return tty_mode_ioctl(tty, file, cmd, arg); in n_tty_ioctl_helper()