tty: Remove TTY_HUPPING
[deliverable/linux.git] / drivers / tty / tty_ldisc.c
index 2d822aa259b2f73ad93212c949e900701d776f04..49001fa2ea2f0084480c2d09ba4c1cd325b12851 100644 (file)
@@ -523,9 +523,11 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
        if (IS_ERR(new_ldisc))
                return PTR_ERR(new_ldisc);
 
+       tty_lock(tty);
        retval = tty_ldisc_lock_pair_timeout(tty, o_tty, 5 * HZ);
        if (retval) {
                tty_ldisc_put(new_ldisc);
+               tty_unlock(tty);
                return retval;
        }
 
@@ -536,14 +538,13 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
        if (tty->ldisc->ops->num == ldisc) {
                tty_ldisc_enable_pair(tty, o_tty);
                tty_ldisc_put(new_ldisc);
+               tty_unlock(tty);
                return 0;
        }
 
        old_ldisc = tty->ldisc;
-       tty_lock(tty);
 
-       if (test_bit(TTY_HUPPING, &tty->flags) ||
-           test_bit(TTY_HUPPED, &tty->flags)) {
+       if (test_bit(TTY_HUPPED, &tty->flags)) {
                /* We were raced by the hangup method. It will have stomped
                   the ldisc data and closed the ldisc down */
                tty_ldisc_enable_pair(tty, o_tty);
@@ -675,8 +676,6 @@ void tty_ldisc_hangup(struct tty_struct *tty)
        wake_up_interruptible_poll(&tty->write_wait, POLLOUT);
        wake_up_interruptible_poll(&tty->read_wait, POLLIN);
 
-       tty_unlock(tty);
-
        /*
         * Shutdown the current line discipline, and reset it to
         * N_TTY if need be.
@@ -684,7 +683,6 @@ void tty_ldisc_hangup(struct tty_struct *tty)
         * Avoid racing set_ldisc or tty_ldisc_release
         */
        tty_ldisc_lock_pair(tty, tty->link);
-       tty_lock(tty);
 
        if (tty->ldisc) {
 
@@ -764,6 +762,8 @@ static void tty_ldisc_kill(struct tty_struct *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.
+ *
+ *     Holding ldisc_sem write lock serializes tty->ldisc changes.
  */
 
 void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
@@ -776,13 +776,9 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
        tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc);
 
        tty_ldisc_lock_pair(tty, o_tty);
-       tty_lock_pair(tty, o_tty);
-
        tty_ldisc_kill(tty);
        if (o_tty)
                tty_ldisc_kill(o_tty);
-
-       tty_unlock_pair(tty, o_tty);
        tty_ldisc_unlock_pair(tty, o_tty);
 
        /* And the memory resources remaining (buffers, termios) will be
This page took 0.026082 seconds and 5 git commands to generate.