aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r--drivers/char/pty.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 328e8ac12306..6e148ade7353 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -391,6 +391,41 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
391 return -ENOIOCTLCMD; 391 return -ENOIOCTLCMD;
392} 392}
393 393
394/**
395 * ptm_unix98_lookup - find a pty master
396 * @driver: ptm driver
397 * @idx: tty index
398 *
399 * Look up a pty master device. Called under the tty_mutex for now.
400 * This provides our locking.
401 */
402
403static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver, int idx)
404{
405 struct tty_struct *tty = devpts_get_tty(idx);
406 if (tty)
407 tty = tty->link;
408 return tty;
409}
410
411/**
412 * pts_unix98_lookup - find a pty slave
413 * @driver: pts driver
414 * @idx: tty index
415 *
416 * Look up a pty master device. Called under the tty_mutex for now.
417 * This provides our locking.
418 */
419
420static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver, int idx)
421{
422 struct tty_struct *tty = devpts_get_tty(idx);
423 /* Master must be open before slave */
424 if (!tty)
425 return ERR_PTR(-EIO);
426 return tty;
427}
428
394static void pty_shutdown(struct tty_struct *tty) 429static void pty_shutdown(struct tty_struct *tty)
395{ 430{
396 /* We have our own method as we don't use the tty index */ 431 /* We have our own method as we don't use the tty index */
@@ -399,6 +434,7 @@ static void pty_shutdown(struct tty_struct *tty)
399} 434}
400 435
401static const struct tty_operations ptm_unix98_ops = { 436static const struct tty_operations ptm_unix98_ops = {
437 .lookup = ptm_unix98_lookup,
402 .open = pty_open, 438 .open = pty_open,
403 .close = pty_close, 439 .close = pty_close,
404 .write = pty_write, 440 .write = pty_write,
@@ -411,6 +447,17 @@ static const struct tty_operations ptm_unix98_ops = {
411 .shutdown = pty_shutdown 447 .shutdown = pty_shutdown
412}; 448};
413 449
450static const struct tty_operations pty_unix98_ops = {
451 .lookup = pts_unix98_lookup,
452 .open = pty_open,
453 .close = pty_close,
454 .write = pty_write,
455 .write_room = pty_write_room,
456 .flush_buffer = pty_flush_buffer,
457 .chars_in_buffer = pty_chars_in_buffer,
458 .unthrottle = pty_unthrottle,
459 .set_termios = pty_set_termios,
460};
414 461
415/** 462/**
416 * ptmx_open - open a unix 98 pty master 463 * ptmx_open - open a unix 98 pty master
@@ -517,7 +564,7 @@ static void __init unix98_pty_init(void)
517 pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 564 pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
518 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM; 565 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
519 pts_driver->other = ptm_driver; 566 pts_driver->other = ptm_driver;
520 tty_set_operations(pts_driver, &pty_ops); 567 tty_set_operations(pts_driver, &pty_unix98_ops);
521 568
522 if (tty_register_driver(ptm_driver)) 569 if (tty_register_driver(ptm_driver))
523 panic("Couldn't register Unix98 ptm driver"); 570 panic("Couldn't register Unix98 ptm driver");