Merge branch 'i2c-embedded/for-next' of git://git.pengutronix.de/git/wsa/linux
[deliverable/linux.git] / drivers / tty / pty.c
index 65c7c62c7aae9b2d81b936a45f0d67f659507324..5505ffc91da4b5780b33af2cac624ea8f696f5e4 100644 (file)
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        wake_up_interruptible(&tty->read_wait);
        wake_up_interruptible(&tty->write_wait);
        tty->packet = 0;
-       /* Review - krefs on tty_link ?? */
        if (!tty->link)
                return;
        tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
                        mutex_unlock(&devpts_mutex);
                }
 #endif
-               tty_unlock(tty);
+               tty_unlock();
                tty_vhangup(tty->link);
-               tty_lock(tty);
+               tty_lock();
        }
 }
 
@@ -623,27 +622,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)
                return retval;
 
        /* find a device that is not in use. */
-       mutex_lock(&devpts_mutex);
+       tty_lock();
        index = devpts_new_index(inode);
+       tty_unlock();
        if (index < 0) {
                retval = index;
                goto err_file;
        }
 
-       mutex_unlock(&devpts_mutex);
-
        mutex_lock(&tty_mutex);
+       mutex_lock(&devpts_mutex);
        tty = tty_init_dev(ptm_driver, index);
+       mutex_unlock(&devpts_mutex);
+       tty_lock();
+       mutex_unlock(&tty_mutex);
 
        if (IS_ERR(tty)) {
                retval = PTR_ERR(tty);
                goto out;
        }
 
-       /* The tty returned here is locked so we can safely
-          drop the mutex */
-       mutex_unlock(&tty_mutex);
-
        set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
 
        tty_add_file(tty, filp);
@@ -656,17 +654,16 @@ static int ptmx_open(struct inode *inode, struct file *filp)
        if (retval)
                goto err_release;
 
-       tty_unlock(tty);
+       tty_unlock();
        return 0;
 err_release:
-       tty_unlock(tty);
+       tty_unlock();
        tty_release(inode, filp);
        return retval;
 out:
-       mutex_unlock(&tty_mutex);
        devpts_kill_index(inode, index);
+       tty_unlock();
 err_file:
-        mutex_unlock(&devpts_mutex);
        tty_free_file(filp);
        return retval;
 }
This page took 0.024726 seconds and 5 git commands to generate.