aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e41b9bbc107d..ea7ebe22a16c 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1271,6 +1271,19 @@ int tty_init_termios(struct tty_struct *tty)
1271} 1271}
1272EXPORT_SYMBOL_GPL(tty_init_termios); 1272EXPORT_SYMBOL_GPL(tty_init_termios);
1273 1273
1274int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
1275{
1276 int ret = tty_init_termios(tty);
1277 if (ret)
1278 return ret;
1279
1280 tty_driver_kref_get(driver);
1281 tty->count++;
1282 driver->ttys[tty->index] = tty;
1283 return 0;
1284}
1285EXPORT_SYMBOL_GPL(tty_standard_install);
1286
1274/** 1287/**
1275 * tty_driver_install_tty() - install a tty entry in the driver 1288 * tty_driver_install_tty() - install a tty entry in the driver
1276 * @driver: the driver for the tty 1289 * @driver: the driver for the tty
@@ -1286,21 +1299,8 @@ EXPORT_SYMBOL_GPL(tty_init_termios);
1286static int tty_driver_install_tty(struct tty_driver *driver, 1299static int tty_driver_install_tty(struct tty_driver *driver,
1287 struct tty_struct *tty) 1300 struct tty_struct *tty)
1288{ 1301{
1289 int idx = tty->index; 1302 return driver->ops->install ? driver->ops->install(driver, tty) :
1290 int ret; 1303 tty_standard_install(driver, tty);
1291
1292 if (driver->ops->install) {
1293 ret = driver->ops->install(driver, tty);
1294 return ret;
1295 }
1296
1297 if (tty_init_termios(tty) == 0) {
1298 tty_driver_kref_get(driver);
1299 tty->count++;
1300 driver->ttys[idx] = tty;
1301 return 0;
1302 }
1303 return -ENOMEM;
1304} 1304}
1305 1305
1306/** 1306/**
@@ -1365,7 +1365,6 @@ static int tty_reopen(struct tty_struct *tty)
1365 * @driver: tty driver we are opening a device on 1365 * @driver: tty driver we are opening a device on
1366 * @idx: device index 1366 * @idx: device index
1367 * @ret_tty: returned tty structure 1367 * @ret_tty: returned tty structure
1368 * @first_ok: ok to open a new device (used by ptmx)
1369 * 1368 *
1370 * Prepare a tty device. This may not be a "new" clean device but 1369 * Prepare a tty device. This may not be a "new" clean device but
1371 * could also be an active device. The pty drivers require special 1370 * could also be an active device. The pty drivers require special
@@ -1385,18 +1384,11 @@ static int tty_reopen(struct tty_struct *tty)
1385 * relaxed for the (most common) case of reopening a tty. 1384 * relaxed for the (most common) case of reopening a tty.
1386 */ 1385 */
1387 1386
1388struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 1387struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1389 int first_ok)
1390{ 1388{
1391 struct tty_struct *tty; 1389 struct tty_struct *tty;
1392 int retval; 1390 int retval;
1393 1391
1394 /* Check if pty master is being opened multiple times */
1395 if (driver->subtype == PTY_TYPE_MASTER &&
1396 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) {
1397 return ERR_PTR(-EIO);
1398 }
1399
1400 /* 1392 /*
1401 * First time open is complex, especially for PTY devices. 1393 * First time open is complex, especially for PTY devices.
1402 * This code guarantees that either everything succeeds and the 1394 * This code guarantees that either everything succeeds and the
@@ -1797,11 +1789,11 @@ int tty_release(struct inode *inode, struct file *filp)
1797 * the slots and preserving the termios structure. 1789 * the slots and preserving the termios structure.
1798 */ 1790 */
1799 release_tty(tty, idx); 1791 release_tty(tty, idx);
1792 tty_unlock();
1800 1793
1801 /* Make this pty number available for reallocation */ 1794 /* Make this pty number available for reallocation */
1802 if (devpts) 1795 if (devpts)
1803 devpts_kill_index(inode, idx); 1796 devpts_kill_index(inode, idx);
1804 tty_unlock();
1805 return 0; 1797 return 0;
1806} 1798}
1807 1799
@@ -1950,7 +1942,7 @@ retry_open:
1950 if (retval) 1942 if (retval)
1951 tty = ERR_PTR(retval); 1943 tty = ERR_PTR(retval);
1952 } else 1944 } else
1953 tty = tty_init_dev(driver, index, 0); 1945 tty = tty_init_dev(driver, index);
1954 1946
1955 mutex_unlock(&tty_mutex); 1947 mutex_unlock(&tty_mutex);
1956 if (driver) 1948 if (driver)