tty_io.c (5f675231e456cb599b283f8361f01cf34b0617df) tty_io.c (f51ccf46217c28758b1f3b5bc0ccfc00eca658b2)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 */
5
6/*
7 * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles
8 * or rs-channels. It also implements echoing, cooked mode etc.

--- 1359 unchanged lines hidden (view full) ---

1368 tty_info_ratelimited(tty, "ldisc open failed (%d), clearing slot %d\n",
1369 retval, idx);
1370err_release_lock:
1371 tty_unlock(tty);
1372 release_tty(tty, idx);
1373 return ERR_PTR(retval);
1374}
1375
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 */
5
6/*
7 * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles
8 * or rs-channels. It also implements echoing, cooked mode etc.

--- 1359 unchanged lines hidden (view full) ---

1368 tty_info_ratelimited(tty, "ldisc open failed (%d), clearing slot %d\n",
1369 retval, idx);
1370err_release_lock:
1371 tty_unlock(tty);
1372 release_tty(tty, idx);
1373 return ERR_PTR(retval);
1374}
1375
1376static void tty_free_termios(struct tty_struct *tty)
1376/**
1377 * tty_save_termios() - save tty termios data in driver table
1378 * @tty: tty whose termios data to save
1379 *
1380 * Locking: Caller guarantees serialisation with tty_init_termios().
1381 */
1382void tty_save_termios(struct tty_struct *tty)
1377{
1378 struct ktermios *tp;
1379 int idx = tty->index;
1380
1381 /* If the port is going to reset then it has no termios to save */
1382 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1383 return;
1384
1385 /* Stash the termios data */
1386 tp = tty->driver->termios[idx];
1387 if (tp == NULL) {
1388 tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
1389 if (tp == NULL)
1390 return;
1391 tty->driver->termios[idx] = tp;
1392 }
1393 *tp = tty->termios;
1394}
1383{
1384 struct ktermios *tp;
1385 int idx = tty->index;
1386
1387 /* If the port is going to reset then it has no termios to save */
1388 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1389 return;
1390
1391 /* Stash the termios data */
1392 tp = tty->driver->termios[idx];
1393 if (tp == NULL) {
1394 tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
1395 if (tp == NULL)
1396 return;
1397 tty->driver->termios[idx] = tp;
1398 }
1399 *tp = tty->termios;
1400}
1401EXPORT_SYMBOL_GPL(tty_save_termios);
1395
1396/**
1397 * tty_flush_works - flush all works of a tty/pty pair
1398 * @tty: tty device to flush works for (or either end of a pty pair)
1399 *
1400 * Sync flush all works belonging to @tty (and the 'other' tty).
1401 */
1402static void tty_flush_works(struct tty_struct *tty)

--- 83 unchanged lines hidden (view full) ---

1486 */
1487static void release_tty(struct tty_struct *tty, int idx)
1488{
1489 /* This should always be true but check for the moment */
1490 WARN_ON(tty->index != idx);
1491 WARN_ON(!mutex_is_locked(&tty_mutex));
1492 if (tty->ops->shutdown)
1493 tty->ops->shutdown(tty);
1402
1403/**
1404 * tty_flush_works - flush all works of a tty/pty pair
1405 * @tty: tty device to flush works for (or either end of a pty pair)
1406 *
1407 * Sync flush all works belonging to @tty (and the 'other' tty).
1408 */
1409static void tty_flush_works(struct tty_struct *tty)

--- 83 unchanged lines hidden (view full) ---

1493 */
1494static void release_tty(struct tty_struct *tty, int idx)
1495{
1496 /* This should always be true but check for the moment */
1497 WARN_ON(tty->index != idx);
1498 WARN_ON(!mutex_is_locked(&tty_mutex));
1499 if (tty->ops->shutdown)
1500 tty->ops->shutdown(tty);
1494 tty_free_termios(tty);
1501 tty_save_termios(tty);
1495 tty_driver_remove_tty(tty->driver, tty);
1496 tty->port->itty = NULL;
1497 if (tty->link)
1498 tty->link->port->itty = NULL;
1499 tty_buffer_cancel_work(tty->port);
1500 if (tty->link)
1501 tty_buffer_cancel_work(tty->link->port);
1502

--- 1989 unchanged lines hidden ---
1502 tty_driver_remove_tty(tty->driver, tty);
1503 tty->port->itty = NULL;
1504 if (tty->link)
1505 tty->link->port->itty = NULL;
1506 tty_buffer_cancel_work(tty->port);
1507 if (tty->link)
1508 tty_buffer_cancel_work(tty->link->port);
1509

--- 1989 unchanged lines hidden ---