diff options
Diffstat (limited to 'drivers/s390/char/tty3270.c')
-rw-r--r-- | drivers/s390/char/tty3270.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 1928f3458d10..482ee028f842 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c | |||
@@ -842,17 +842,14 @@ static struct raw3270_fn tty3270_fn = { | |||
842 | }; | 842 | }; |
843 | 843 | ||
844 | /* | 844 | /* |
845 | * This routine is called whenever a 3270 tty is opened. | 845 | * This routine is called whenever a 3270 tty is opened first time. |
846 | */ | 846 | */ |
847 | static int | 847 | static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) |
848 | tty3270_open(struct tty_struct *tty, struct file * filp) | ||
849 | { | 848 | { |
850 | struct raw3270_view *view; | 849 | struct raw3270_view *view; |
851 | struct tty3270 *tp; | 850 | struct tty3270 *tp; |
852 | int i, rc; | 851 | int i, rc; |
853 | 852 | ||
854 | if (tty->count > 1) | ||
855 | return 0; | ||
856 | /* Check if the tty3270 is already there. */ | 853 | /* Check if the tty3270 is already there. */ |
857 | view = raw3270_find_view(&tty3270_fn, | 854 | view = raw3270_find_view(&tty3270_fn, |
858 | tty->index + RAW3270_FIRSTMINOR); | 855 | tty->index + RAW3270_FIRSTMINOR); |
@@ -865,7 +862,7 @@ tty3270_open(struct tty_struct *tty, struct file * filp) | |||
865 | /* why to reassign? */ | 862 | /* why to reassign? */ |
866 | tty_port_tty_set(&tp->port, tty); | 863 | tty_port_tty_set(&tp->port, tty); |
867 | tp->inattr = TF_INPUT; | 864 | tp->inattr = TF_INPUT; |
868 | return 0; | 865 | return tty_port_install(&tp->port, driver, tty); |
869 | } | 866 | } |
870 | if (tty3270_max_index < tty->index + 1) | 867 | if (tty3270_max_index < tty->index + 1) |
871 | tty3270_max_index = tty->index + 1; | 868 | tty3270_max_index = tty->index + 1; |
@@ -895,7 +892,6 @@ tty3270_open(struct tty_struct *tty, struct file * filp) | |||
895 | 892 | ||
896 | tty_port_tty_set(&tp->port, tty); | 893 | tty_port_tty_set(&tp->port, tty); |
897 | tty->low_latency = 0; | 894 | tty->low_latency = 0; |
898 | tty->driver_data = tp; | ||
899 | tty->winsize.ws_row = tp->view.rows - 2; | 895 | tty->winsize.ws_row = tp->view.rows - 2; |
900 | tty->winsize.ws_col = tp->view.cols; | 896 | tty->winsize.ws_col = tp->view.cols; |
901 | 897 | ||
@@ -915,6 +911,15 @@ tty3270_open(struct tty_struct *tty, struct file * filp) | |||
915 | kbd_ascebc(tp->kbd, tp->view.ascebc); | 911 | kbd_ascebc(tp->kbd, tp->view.ascebc); |
916 | 912 | ||
917 | raw3270_activate_view(&tp->view); | 913 | raw3270_activate_view(&tp->view); |
914 | |||
915 | rc = tty_port_install(&tp->port, driver, tty); | ||
916 | if (rc) { | ||
917 | raw3270_put_view(&tp->view); | ||
918 | return rc; | ||
919 | } | ||
920 | |||
921 | tty->driver_data = tp; | ||
922 | |||
918 | return 0; | 923 | return 0; |
919 | } | 924 | } |
920 | 925 | ||
@@ -932,10 +937,17 @@ tty3270_close(struct tty_struct *tty, struct file * filp) | |||
932 | if (tp) { | 937 | if (tp) { |
933 | tty->driver_data = NULL; | 938 | tty->driver_data = NULL; |
934 | tty_port_tty_set(&tp->port, NULL); | 939 | tty_port_tty_set(&tp->port, NULL); |
935 | raw3270_put_view(&tp->view); | ||
936 | } | 940 | } |
937 | } | 941 | } |
938 | 942 | ||
943 | static void tty3270_cleanup(struct tty_struct *tty) | ||
944 | { | ||
945 | struct tty3270 *tp = tty->driver_data; | ||
946 | |||
947 | if (tp) | ||
948 | raw3270_put_view(&tp->view); | ||
949 | } | ||
950 | |||
939 | /* | 951 | /* |
940 | * We always have room. | 952 | * We always have room. |
941 | */ | 953 | */ |
@@ -1737,7 +1749,8 @@ static long tty3270_compat_ioctl(struct tty_struct *tty, | |||
1737 | #endif | 1749 | #endif |
1738 | 1750 | ||
1739 | static const struct tty_operations tty3270_ops = { | 1751 | static const struct tty_operations tty3270_ops = { |
1740 | .open = tty3270_open, | 1752 | .install = tty3270_install, |
1753 | .cleanup = tty3270_cleanup, | ||
1741 | .close = tty3270_close, | 1754 | .close = tty3270_close, |
1742 | .write = tty3270_write, | 1755 | .write = tty3270_write, |
1743 | .put_char = tty3270_put_char, | 1756 | .put_char = tty3270_put_char, |
@@ -1781,7 +1794,7 @@ static int __init tty3270_init(void) | |||
1781 | driver->type = TTY_DRIVER_TYPE_SYSTEM; | 1794 | driver->type = TTY_DRIVER_TYPE_SYSTEM; |
1782 | driver->subtype = SYSTEM_TYPE_TTY; | 1795 | driver->subtype = SYSTEM_TYPE_TTY; |
1783 | driver->init_termios = tty_std_termios; | 1796 | driver->init_termios = tty_std_termios; |
1784 | driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_DYNAMIC_DEV; | 1797 | driver->flags = TTY_DRIVER_RESET_TERMIOS; |
1785 | tty_set_operations(driver, &tty3270_ops); | 1798 | tty_set_operations(driver, &tty3270_ops); |
1786 | ret = tty_register_driver(driver); | 1799 | ret = tty_register_driver(driver); |
1787 | if (ret) { | 1800 | if (ret) { |
@@ -1800,6 +1813,7 @@ tty3270_exit(void) | |||
1800 | driver = tty3270_driver; | 1813 | driver = tty3270_driver; |
1801 | tty3270_driver = NULL; | 1814 | tty3270_driver = NULL; |
1802 | tty_unregister_driver(driver); | 1815 | tty_unregister_driver(driver); |
1816 | put_tty_driver(driver); | ||
1803 | tty3270_del_views(); | 1817 | tty3270_del_views(); |
1804 | } | 1818 | } |
1805 | 1819 | ||