summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSukadev Bhattiprolu <sukadev@us.ibm.com>2008-10-13 10:42:49 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 09:51:43 -0700
commit4a2b5fddd53b80efcb3266ee36e23b8de28e761a (patch)
treeecb39392a17d1e9f0668c21064e3aa4207700e76
parentbf970ee46e0fb363c8df4393229121d54330a98e (diff)
downloadlinux-4a2b5fddd53b80efcb3266ee36e23b8de28e761a.tar.bz2
Move tty lookup/reopen to caller
Move tty_driver_lookup_tty() and tty_reopen() from tty_init_dev() into tty_open() (one of the two callers of tty_init_dev()). These calls are not really required in ptmx_open(), the other caller, since ptmx_open() would be setting up a new tty. Changelog[v2]: - remove the lookup and reopen calls from ptmx_open - merge with recent changes to ttydev tree Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/tty_io.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e881e9ed08de..36098ee8fe65 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1376,19 +1376,6 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
struct tty_struct *tty;
int retval;
- /* check whether we're reopening an existing tty */
- tty = tty_driver_lookup_tty(driver, idx);
-
- if (IS_ERR(tty))
- return tty;
-
- if (tty) {
- retval = tty_reopen(tty);
- if (retval)
- return ERR_PTR(retval);
- return tty;
- }
-
/* Check if pty master is being opened multiple times */
if (driver->subtype == PTY_TYPE_MASTER &&
(driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok)
@@ -1790,7 +1777,7 @@ void tty_release_dev(struct file *filp)
static int __tty_open(struct inode *inode, struct file *filp)
{
- struct tty_struct *tty;
+ struct tty_struct *tty = NULL;
int noctty, retval;
struct tty_driver *driver;
int index;
@@ -1847,7 +1834,21 @@ retry_open:
return -ENODEV;
}
got_driver:
- tty = tty_init_dev(driver, index, 0);
+ if (!tty) {
+ /* check whether we're reopening an existing tty */
+ tty = tty_driver_lookup_tty(driver, index);
+
+ if (IS_ERR(tty))
+ return PTR_ERR(tty);
+ }
+
+ if (tty) {
+ retval = tty_reopen(tty);
+ if (retval)
+ tty = ERR_PTR(retval);
+ } else
+ tty = tty_init_dev(driver, index, 0);
+
mutex_unlock(&tty_mutex);
tty_driver_kref_put(driver);
if (IS_ERR(tty))