diff options
author | Alan Cox <alan@redhat.com> | 2008-10-13 05:42:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 12:51:42 -0400 |
commit | 99f1fe189daf8e99a847e420567e49dd7ee2aae7 (patch) | |
tree | 09db410aa2b32e74086593eb771c75efe553a585 /drivers/char/pty.c | |
parent | 23499705753ab8b4c6b0b64e6c424a370bd900a1 (diff) |
tty: Clean up the tty_init_dev changes further
Fix up the naming, style and extract some bits of code into the driver
specific code
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r-- | drivers/char/pty.c | 49 |
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 | |||
403 | static 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 | |||
420 | static 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 | |||
394 | static void pty_shutdown(struct tty_struct *tty) | 429 | static 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 | ||
401 | static const struct tty_operations ptm_unix98_ops = { | 436 | static 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 | ||
450 | static 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"); |