/* Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened.  */
void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
/* Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened.  */
void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
{
	tty_ldisc_halt(tty);
	flush_scheduled_work();
	mutex_lock(&tty->ldisc_mutex);
	tty_ldisc_close(tty, tty->ldisc);
	tty_ldisc_put(tty->ldisc);
	tty->ldisc = NULL;
	tty_set_termios_ldisc(tty, N_TTY);
	mutex_unlock(&tty->ldisc_mutex);
	if (o_tty)
		tty_ldisc_release(o_tty, NULL);
}