Commit fa2ecfc5 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: move devpts kill to pty

Now that we have control over tty->driver_data in pty, we can just
kill the /dev/pts/ in pty code too. Namely, in ->shutdown hook of
tty. For pty, this is called only once, for whichever end is closed
last. But we don't care, both driver_data are the inode as it used to
be till now.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Acked-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1dcb8e6d
...@@ -363,6 +363,12 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, ...@@ -363,6 +363,12 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
return retval; return retval;
} }
/* this is called once with whichever end is closed last */
static void pty_unix98_shutdown(struct tty_struct *tty)
{
devpts_kill_index(tty->driver_data, tty->index);
}
static void pty_cleanup(struct tty_struct *tty) static void pty_cleanup(struct tty_struct *tty)
{ {
kfree(tty->port); kfree(tty->port);
...@@ -578,6 +584,7 @@ static const struct tty_operations ptm_unix98_ops = { ...@@ -578,6 +584,7 @@ static const struct tty_operations ptm_unix98_ops = {
.set_termios = pty_set_termios, .set_termios = pty_set_termios,
.ioctl = pty_unix98_ioctl, .ioctl = pty_unix98_ioctl,
.resize = pty_resize, .resize = pty_resize,
.shutdown = pty_unix98_shutdown,
.cleanup = pty_cleanup .cleanup = pty_cleanup
}; };
...@@ -593,6 +600,7 @@ static const struct tty_operations pty_unix98_ops = { ...@@ -593,6 +600,7 @@ static const struct tty_operations pty_unix98_ops = {
.chars_in_buffer = pty_chars_in_buffer, .chars_in_buffer = pty_chars_in_buffer,
.unthrottle = pty_unthrottle, .unthrottle = pty_unthrottle,
.set_termios = pty_set_termios, .set_termios = pty_set_termios,
.shutdown = pty_unix98_shutdown,
.cleanup = pty_cleanup, .cleanup = pty_cleanup,
}; };
...@@ -661,6 +669,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) ...@@ -661,6 +669,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
goto err_release; goto err_release;
tty_unlock(tty); tty_unlock(tty);
tty->driver_data = inode;
tty->link->driver_data = slave_inode; tty->link->driver_data = slave_inode;
return 0; return 0;
err_release: err_release:
......
...@@ -1625,7 +1625,6 @@ int tty_release(struct inode *inode, struct file *filp) ...@@ -1625,7 +1625,6 @@ int tty_release(struct inode *inode, struct file *filp)
struct tty_struct *tty = file_tty(filp); struct tty_struct *tty = file_tty(filp);
struct tty_struct *o_tty; struct tty_struct *o_tty;
int pty_master, tty_closing, o_tty_closing, do_sleep; int pty_master, tty_closing, o_tty_closing, do_sleep;
int devpts;
int idx; int idx;
char buf[64]; char buf[64];
...@@ -1640,7 +1639,6 @@ int tty_release(struct inode *inode, struct file *filp) ...@@ -1640,7 +1639,6 @@ int tty_release(struct inode *inode, struct file *filp)
idx = tty->index; idx = tty->index;
pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER); tty->driver->subtype == PTY_TYPE_MASTER);
devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
/* Review: parallel close */ /* Review: parallel close */
o_tty = tty->link; o_tty = tty->link;
...@@ -1799,9 +1797,6 @@ int tty_release(struct inode *inode, struct file *filp) ...@@ -1799,9 +1797,6 @@ int tty_release(struct inode *inode, struct file *filp)
release_tty(tty, idx); release_tty(tty, idx);
mutex_unlock(&tty_mutex); mutex_unlock(&tty_mutex);
/* Make this pty number available for reallocation */
if (devpts)
devpts_kill_index(inode, idx);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment