aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSukadev Bhattiprolu <sukadev@us.ibm.com>2008-10-13 05:42:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:43 -0400
commit4a2b5fddd53b80efcb3266ee36e23b8de28e761a (patch)
treeecb39392a17d1e9f0668c21064e3aa4207700e76
parentbf970ee46e0fb363c8df4393229121d54330a98e (diff)
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,
1376 struct tty_struct *tty; 1376 struct tty_struct *tty;
1377 int retval; 1377 int retval;
1378 1378
1379 /* check whether we're reopening an existing tty */
1380 tty = tty_driver_lookup_tty(driver, idx);
1381
1382 if (IS_ERR(tty))
1383 return tty;
1384
1385 if (tty) {
1386 retval = tty_reopen(tty);
1387 if (retval)
1388 return ERR_PTR(retval);
1389 return tty;
1390 }
1391
1392 /* Check if pty master is being opened multiple times */ 1379 /* Check if pty master is being opened multiple times */
1393 if (driver->subtype == PTY_TYPE_MASTER && 1380 if (driver->subtype == PTY_TYPE_MASTER &&
1394 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) 1381 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok)
@@ -1790,7 +1777,7 @@ void tty_release_dev(struct file *filp)
1790 1777
1791static int __tty_open(struct inode *inode, struct file *filp) 1778static int __tty_open(struct inode *inode, struct file *filp)
1792{ 1779{
1793 struct tty_struct *tty; 1780 struct tty_struct *tty = NULL;
1794 int noctty, retval; 1781 int noctty, retval;
1795 struct tty_driver *driver; 1782 struct tty_driver *driver;
1796 int index; 1783 int index;
@@ -1847,7 +1834,21 @@ retry_open:
1847 return -ENODEV; 1834 return -ENODEV;
1848 } 1835 }
1849got_driver: 1836got_driver:
1850 tty = tty_init_dev(driver, index, 0); 1837 if (!tty) {
1838 /* check whether we're reopening an existing tty */
1839 tty = tty_driver_lookup_tty(driver, index);
1840
1841 if (IS_ERR(tty))
1842 return PTR_ERR(tty);
1843 }
1844
1845 if (tty) {
1846 retval = tty_reopen(tty);
1847 if (retval)
1848 tty = ERR_PTR(retval);
1849 } else
1850 tty = tty_init_dev(driver, index, 0);
1851
1851 mutex_unlock(&tty_mutex); 1852 mutex_unlock(&tty_mutex);
1852 tty_driver_kref_put(driver); 1853 tty_driver_kref_put(driver);
1853 if (IS_ERR(tty)) 1854 if (IS_ERR(tty))