Skip to contentSkip to conversation

s390 (4/6): 3270 console driver.

PATCH New Martin Schwidefsky 1 participant 1 message May 13, 2004 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390 (4/6): 3270 console driver.

[PATCH] s390: 3270 driver.

From: Martin Schwidefsky <[email protected]>

3270 device driver change:
- Don't allow activation of views while the initial size sensing is still in progress. Replace RAW3270_FLAGS_SHUTDOWN with RAW3270_FLAGS_READY.
- Make 3270 views loadable as modules.

diffstat:

 arch/s390/defconfig         |    2 
 drivers/s390/Kconfig        |   25 ++++++--
 drivers/s390/char/Makefile  |    5 +
 drivers/s390/char/raw3270.c |  129 +++++++++++++++++++++++++++++++-------------
 drivers/s390/char/raw3270.h |    7 +-
 drivers/s390/char/tty3270.c |   37 +++++++++++-
 6 files changed, 153 insertions(+), 52 deletions(-)
arch/s390/defconfig +2 -0
diff -urN linux-2.6/arch/s390/defconfig linux-2.6-s390/arch/s390/defconfig
@@ -178,6 +178,8 @@
 # S/390 character device drivers
 #
 CONFIG_TN3270=y
+CONFIG_TN3270_TTY=y
+CONFIG_TN3270_FS=m
 CONFIG_TN3270_CONSOLE=y
 CONFIG_TN3215=y
 CONFIG_TN3215_CONSOLE=y
drivers/s390/Kconfig +18 -7
diff -urN linux-2.6/drivers/s390/Kconfig linux-2.6-s390/drivers/s390/Kconfig
@@ -54,17 +54,28 @@
 comment "S/390 character device drivers"
 
 config TN3270
-	tristate "Support for locally attached 3270 tubes"
+	tristate "Support for locally attached 3270 terminals"
 	help
-	  Include support for IBM 3270 line-mode terminals.
+	  Include support for IBM 3270 terminals.
+
+config TN3270_TTY
+	tristate "Support for tty input/output on 3270 terminals"
+	depends on TN3270
+	help
+	  Include support for using an IBM 3270 terminal as a Linux tty.
+
+config TN3270_FS
+	tristate "Support for fullscreen applications on 3270 terminals"
+	depends on TN3270
+	help
+	  Include support for fullscreen applications on an IBM 3270 terminal.
 
 config TN3270_CONSOLE
-	bool "Support for console on 3270 line mode terminal"
-	depends on TN3270=y
+	bool "Support for console on 3270 terminal"
+	depends on TN3270=y && TN3270_TTY=y
 	help
-	  Include support for using an IBM 3270 line-mode terminal as a Linux
-	  system console.  Available only if 3270 support is compiled in
-	  statically.
+	  Include support for using an IBM 3270 terminal as a Linux system
+	  console.  Available only if 3270 support is compiled in statically.
 
 config TN3215
 	bool "Support for 3215 line mode terminal"
drivers/s390/char/Makefile +3 -2
diff -urN linux-2.6/drivers/s390/char/Makefile linux-2.6-s390/drivers/s390/char/Makefile
@@ -4,9 +4,10 @@
 
 obj-y += ctrlchar.o keyboard.o defkeymap.o
 
-tub3270-objs := raw3270.o tty3270.o fs3270.o
-obj-$(CONFIG_TN3270) += tub3270.o
+obj-$(CONFIG_TN3270) += raw3270.o
 obj-$(CONFIG_TN3270_CONSOLE) += con3270.o
+obj-$(CONFIG_TN3270_TTY) += tty3270.o
+obj-$(CONFIG_TN3270_FS) += fs3270.o
 
 obj-$(CONFIG_TN3215) += con3215.o
 
drivers/s390/char/raw3270.c +93 -36

308 lines not on this page · raw message

drivers/s390/char/raw3270.h +4 -3
diff -urN linux-2.6/drivers/s390/char/raw3270.h linux-2.6-s390/drivers/s390/char/raw3270.h
@@ -78,9 +78,6 @@
 
 #define RAW3270_MAXDEVS	256
 
-int raw3270_init(void);
-void raw3270_exit(void);
-
 /* For TUBGETMOD and TUBSETMOD. Should include. */
 struct raw3270_iocb {
 	short model;
@@ -190,6 +187,10 @@
 struct raw3270 *raw3270_setup_console(struct ccw_device *cdev);
 void raw3270_wait_cons_dev(struct raw3270 *);
 
+/* Notifier for device addition/removal */
+int raw3270_register_notifier(void (*notifier)(int, int));
+void raw3270_unregister_notifier(void (*notifier)(int, int));
+
 /*
  * Little memory allocator for string objects. 
  */
drivers/s390/char/tty3270.c +33 -4
diff -urN linux-2.6/drivers/s390/char/tty3270.c linux-2.6-s390/drivers/s390/char/tty3270.c
@@ -35,6 +35,7 @@
 #define TTY3270_STRING_PAGES 5
 
 struct tty_driver *tty3270_driver;
+static int tty3270_max_index;
 
 struct raw3270_fn tty3270_fn;
 
@@ -836,6 +837,22 @@
 	tty3270_free_view((struct tty3270 *) view);
 }
 
+/*
+ * Delayed freeing of tty3270 views.
+ */
+static void
+tty3270_del_views(void)
+{
+	struct tty3270 *tp;
+	int i;
+
+	for (i = 0; i < tty3270_max_index; i++) {
+		tp = (struct tty3270 *) raw3270_find_view(&tty3270_fn, i);
+		if (!IS_ERR(tp))
+			raw3270_del_view(&tp->view);
+	}
+}
+
 struct raw3270_fn tty3270_fn = {
 	.activate = tty3270_activate,
 	.deactivate = tty3270_deactivate,
@@ -867,6 +884,12 @@
 		tp->inattr = TF_INPUT;
 		return 0;
 	}
+	if (tty3270_max_index < tty->index + 1)
+		tty3270_max_index = tty->index + 1;
+
+	/* Quick exit if there is no device for tty->index. */
+	if (PTR_ERR(tp) == -ENODEV)
+		return -ENODEV;
 
 	/* Allocate tty3270 structure on first open. */
 	tp = tty3270_alloc_view();
@@ -1778,9 +1801,6 @@
 	struct tty_driver *driver;
 	int ret;
 
-	ret = raw3270_init();
-	if (ret)
-		return ret;
 	driver = alloc_tty_driver(256);
 	if (!driver)
 		return -ENOMEM;
@@ -1807,6 +1827,14 @@
 		return ret;
 	}
 	tty3270_driver = driver;
+	ret = raw3270_register_notifier(tty3270_notifier);
+	if (ret) {
+		printk(KERN_ERR "tty3270 notifier registration failed "
+		       "with %d\n", ret);
+		put_tty_driver(driver);
+		return ret;
+
+	}
 	return 0;
 }
 
@@ -1815,10 +1843,11 @@
 {
 	struct tty_driver *driver;
 
+	raw3270_unregister_notifier(tty3270_notifier);
 	driver = tty3270_driver;
 	tty3270_driver = 0;
 	tty_unregister_driver(driver);
-	raw3270_exit();
+	tty3270_del_views();
 }
 
 MODULE_LICENSE("GPL");