diff options
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r-- | drivers/tty/tty_io.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 2ea176b2280e..da9fde850754 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -186,7 +186,6 @@ void free_tty_struct(struct tty_struct *tty) | |||
186 | if (tty->dev) | 186 | if (tty->dev) |
187 | put_device(tty->dev); | 187 | put_device(tty->dev); |
188 | kfree(tty->write_buf); | 188 | kfree(tty->write_buf); |
189 | tty_buffer_free_all(tty); | ||
190 | tty->magic = 0xDEADDEAD; | 189 | tty->magic = 0xDEADDEAD; |
191 | kfree(tty); | 190 | kfree(tty); |
192 | } | 191 | } |
@@ -237,7 +236,7 @@ void tty_free_file(struct file *file) | |||
237 | } | 236 | } |
238 | 237 | ||
239 | /* Delete file from its tty */ | 238 | /* Delete file from its tty */ |
240 | void tty_del_file(struct file *file) | 239 | static void tty_del_file(struct file *file) |
241 | { | 240 | { |
242 | struct tty_file_private *priv = file->private_data; | 241 | struct tty_file_private *priv = file->private_data; |
243 | 242 | ||
@@ -555,7 +554,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup); | |||
555 | * tasklist_lock to walk task list for hangup event | 554 | * tasklist_lock to walk task list for hangup event |
556 | * ->siglock to protect ->signal/->sighand | 555 | * ->siglock to protect ->signal/->sighand |
557 | */ | 556 | */ |
558 | void __tty_hangup(struct tty_struct *tty) | 557 | static void __tty_hangup(struct tty_struct *tty) |
559 | { | 558 | { |
560 | struct file *cons_filp = NULL; | 559 | struct file *cons_filp = NULL; |
561 | struct file *filp, *f = NULL; | 560 | struct file *filp, *f = NULL; |
@@ -1417,6 +1416,8 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) | |||
1417 | "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", | 1416 | "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", |
1418 | __func__, tty->driver->name); | 1417 | __func__, tty->driver->name); |
1419 | 1418 | ||
1419 | tty->port->itty = tty; | ||
1420 | |||
1420 | /* | 1421 | /* |
1421 | * Structures all installed ... call the ldisc open routines. | 1422 | * Structures all installed ... call the ldisc open routines. |
1422 | * If we fail here just call release_tty to clean up. No need | 1423 | * If we fail here just call release_tty to clean up. No need |
@@ -1552,6 +1553,7 @@ static void release_tty(struct tty_struct *tty, int idx) | |||
1552 | tty->ops->shutdown(tty); | 1553 | tty->ops->shutdown(tty); |
1553 | tty_free_termios(tty); | 1554 | tty_free_termios(tty); |
1554 | tty_driver_remove_tty(tty->driver, tty); | 1555 | tty_driver_remove_tty(tty->driver, tty); |
1556 | tty->port->itty = NULL; | ||
1555 | 1557 | ||
1556 | if (tty->link) | 1558 | if (tty->link) |
1557 | tty_kref_put(tty->link); | 1559 | tty_kref_put(tty->link); |
@@ -1625,7 +1627,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1625 | struct tty_struct *tty = file_tty(filp); | 1627 | struct tty_struct *tty = file_tty(filp); |
1626 | struct tty_struct *o_tty; | 1628 | struct tty_struct *o_tty; |
1627 | int pty_master, tty_closing, o_tty_closing, do_sleep; | 1629 | int pty_master, tty_closing, o_tty_closing, do_sleep; |
1628 | int devpts; | ||
1629 | int idx; | 1630 | int idx; |
1630 | char buf[64]; | 1631 | char buf[64]; |
1631 | 1632 | ||
@@ -1640,7 +1641,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1640 | idx = tty->index; | 1641 | idx = tty->index; |
1641 | pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && | 1642 | pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && |
1642 | tty->driver->subtype == PTY_TYPE_MASTER); | 1643 | tty->driver->subtype == PTY_TYPE_MASTER); |
1643 | devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0; | ||
1644 | /* Review: parallel close */ | 1644 | /* Review: parallel close */ |
1645 | o_tty = tty->link; | 1645 | o_tty = tty->link; |
1646 | 1646 | ||
@@ -1799,9 +1799,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1799 | release_tty(tty, idx); | 1799 | release_tty(tty, idx); |
1800 | mutex_unlock(&tty_mutex); | 1800 | mutex_unlock(&tty_mutex); |
1801 | 1801 | ||
1802 | /* Make this pty number available for reallocation */ | ||
1803 | if (devpts) | ||
1804 | devpts_kill_index(inode, idx); | ||
1805 | return 0; | 1802 | return 0; |
1806 | } | 1803 | } |
1807 | 1804 | ||
@@ -2690,6 +2687,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2690 | case TIOCNXCL: | 2687 | case TIOCNXCL: |
2691 | clear_bit(TTY_EXCLUSIVE, &tty->flags); | 2688 | clear_bit(TTY_EXCLUSIVE, &tty->flags); |
2692 | return 0; | 2689 | return 0; |
2690 | case TIOCGEXCL: | ||
2691 | { | ||
2692 | int excl = test_bit(TTY_EXCLUSIVE, &tty->flags); | ||
2693 | return put_user(excl, (int __user *)p); | ||
2694 | } | ||
2693 | case TIOCNOTTY: | 2695 | case TIOCNOTTY: |
2694 | if (current->signal->tty != tty) | 2696 | if (current->signal->tty != tty) |
2695 | return -ENOTTY; | 2697 | return -ENOTTY; |
@@ -2937,19 +2939,13 @@ void initialize_tty_struct(struct tty_struct *tty, | |||
2937 | tty_ldisc_init(tty); | 2939 | tty_ldisc_init(tty); |
2938 | tty->session = NULL; | 2940 | tty->session = NULL; |
2939 | tty->pgrp = NULL; | 2941 | tty->pgrp = NULL; |
2940 | tty->overrun_time = jiffies; | ||
2941 | tty_buffer_init(tty); | ||
2942 | mutex_init(&tty->legacy_mutex); | 2942 | mutex_init(&tty->legacy_mutex); |
2943 | mutex_init(&tty->termios_mutex); | 2943 | mutex_init(&tty->termios_mutex); |
2944 | mutex_init(&tty->ldisc_mutex); | 2944 | mutex_init(&tty->ldisc_mutex); |
2945 | init_waitqueue_head(&tty->write_wait); | 2945 | init_waitqueue_head(&tty->write_wait); |
2946 | init_waitqueue_head(&tty->read_wait); | 2946 | init_waitqueue_head(&tty->read_wait); |
2947 | INIT_WORK(&tty->hangup_work, do_tty_hangup); | 2947 | INIT_WORK(&tty->hangup_work, do_tty_hangup); |
2948 | mutex_init(&tty->atomic_read_lock); | ||
2949 | mutex_init(&tty->atomic_write_lock); | 2948 | mutex_init(&tty->atomic_write_lock); |
2950 | mutex_init(&tty->output_lock); | ||
2951 | mutex_init(&tty->echo_lock); | ||
2952 | spin_lock_init(&tty->read_lock); | ||
2953 | spin_lock_init(&tty->ctrl_lock); | 2949 | spin_lock_init(&tty->ctrl_lock); |
2954 | INIT_LIST_HEAD(&tty->tty_files); | 2950 | INIT_LIST_HEAD(&tty->tty_files); |
2955 | INIT_WORK(&tty->SAK_work, do_SAK_work); | 2951 | INIT_WORK(&tty->SAK_work, do_SAK_work); |