aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:48:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-13 19:53:14 -0400
commit20cda6f25f9edaa26638fc32e88241af135d712d (patch)
tree73f6a873370200fad67417f9ccc933c42a2610a9 /drivers/s390/char
parent9c650ffc27b444f5370ae5e8bc84df76584416a0 (diff)
TTY: tty3270, add tty install
This has two outcomes: * we give the TTY layer a tty_port * we do not find the info structure every time open is called on that tty In this case ->install is the only thing we want to do. We do not need ->open at all. See the tty->count > 1 check. And since we take a reference in ->install, we need also ->cleanup to drop the reference to a view. Final note, see that we leave raw3270_find_view in place. It is because views are removed even from module_exit. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: linux390@de.ibm.com Cc: linux-s390@vger.kernel.org Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/s390/char')
-rw-r--r--drivers/s390/char/tty3270.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index f2b8c6c533e8..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 */
847static int 847static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty)
848tty3270_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
943static 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
1739static const struct tty_operations tty3270_ops = { 1751static 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,