aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/tty3270.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2013-01-08 09:31:11 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-02-14 09:55:02 -0500
commitc95571e68086d36e8e3369597b03ec29c63abec9 (patch)
tree20cb4b0f1f9bbf49375ab6a6458668fd726f6841 /drivers/s390/char/tty3270.c
parent57985d7e1e48f16548aa6904264e21bca15af0fc (diff)
s390/3270: introduce device notifier
Add a notifier to create / destroy the device nodes for the tty view and the fullscreen view. Only device nodes for online devices are created and the device names will follow the convention as outlined in Documentation/devices.txt: 3270/tty<x> for the tty nodes, 3270/tub<x> for hte fullscreen nodes and 3270/tub for the fullscreen control node. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/tty3270.c')
-rw-r--r--drivers/s390/char/tty3270.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 5e4b6fc49ae3..48767e6bab9d 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -829,9 +829,8 @@ tty3270_del_views(void)
829{ 829{
830 int i; 830 int i;
831 831
832 for (i = 0; i < tty3270_max_index; i++) { 832 for (i = RAW3270_FIRSTMINOR; i <= tty3270_max_index; i++) {
833 struct raw3270_view *view = 833 struct raw3270_view *view = raw3270_find_view(&tty3270_fn, i);
834 raw3270_find_view(&tty3270_fn, i + RAW3270_FIRSTMINOR);
835 if (!IS_ERR(view)) 834 if (!IS_ERR(view))
836 raw3270_del_view(view); 835 raw3270_del_view(view);
837 } 836 }
@@ -855,8 +854,7 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty)
855 int i, rc; 854 int i, rc;
856 855
857 /* Check if the tty3270 is already there. */ 856 /* Check if the tty3270 is already there. */
858 view = raw3270_find_view(&tty3270_fn, 857 view = raw3270_find_view(&tty3270_fn, tty->index);
859 tty->index + RAW3270_FIRSTMINOR);
860 if (!IS_ERR(view)) { 858 if (!IS_ERR(view)) {
861 tp = container_of(view, struct tty3270, view); 859 tp = container_of(view, struct tty3270, view);
862 tty->driver_data = tp; 860 tty->driver_data = tp;
@@ -868,8 +866,8 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty)
868 tp->inattr = TF_INPUT; 866 tp->inattr = TF_INPUT;
869 return tty_port_install(&tp->port, driver, tty); 867 return tty_port_install(&tp->port, driver, tty);
870 } 868 }
871 if (tty3270_max_index < tty->index + 1) 869 if (tty3270_max_index < tty->index)
872 tty3270_max_index = tty->index + 1; 870 tty3270_max_index = tty->index;
873 871
874 /* Quick exit if there is no device for tty->index. */ 872 /* Quick exit if there is no device for tty->index. */
875 if (PTR_ERR(view) == -ENODEV) 873 if (PTR_ERR(view) == -ENODEV)
@@ -880,8 +878,7 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty)
880 if (IS_ERR(tp)) 878 if (IS_ERR(tp))
881 return PTR_ERR(tp); 879 return PTR_ERR(tp);
882 880
883 rc = raw3270_add_view(&tp->view, &tty3270_fn, 881 rc = raw3270_add_view(&tp->view, &tty3270_fn, tty->index);
884 tty->index + RAW3270_FIRSTMINOR);
885 if (rc) { 882 if (rc) {
886 tty3270_free_view(tp); 883 tty3270_free_view(tp);
887 return rc; 884 return rc;
@@ -1788,6 +1785,22 @@ static const struct tty_operations tty3270_ops = {
1788 .set_termios = tty3270_set_termios 1785 .set_termios = tty3270_set_termios
1789}; 1786};
1790 1787
1788void tty3270_create_cb(int minor)
1789{
1790 tty_register_device(tty3270_driver, minor, NULL);
1791}
1792
1793void tty3270_destroy_cb(int minor)
1794{
1795 tty_unregister_device(tty3270_driver, minor);
1796}
1797
1798struct raw3270_notifier tty3270_notifier =
1799{
1800 .create = tty3270_create_cb,
1801 .destroy = tty3270_destroy_cb,
1802};
1803
1791/* 1804/*
1792 * 3270 tty registration code called from tty_init(). 1805 * 3270 tty registration code called from tty_init().
1793 * Most kernel services (incl. kmalloc) are available at this poimt. 1806 * Most kernel services (incl. kmalloc) are available at this poimt.
@@ -1797,23 +1810,25 @@ static int __init tty3270_init(void)
1797 struct tty_driver *driver; 1810 struct tty_driver *driver;
1798 int ret; 1811 int ret;
1799 1812
1800 driver = alloc_tty_driver(RAW3270_MAXDEVS); 1813 driver = tty_alloc_driver(RAW3270_MAXDEVS,
1801 if (!driver) 1814 TTY_DRIVER_REAL_RAW |
1802 return -ENOMEM; 1815 TTY_DRIVER_DYNAMIC_DEV |
1816 TTY_DRIVER_RESET_TERMIOS);
1817 if (IS_ERR(driver))
1818 return PTR_ERR(driver);
1803 1819
1804 /* 1820 /*
1805 * Initialize the tty_driver structure 1821 * Initialize the tty_driver structure
1806 * Entries in tty3270_driver that are NOT initialized: 1822 * Entries in tty3270_driver that are NOT initialized:
1807 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc 1823 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
1808 */ 1824 */
1809 driver->driver_name = "ttyTUB"; 1825 driver->driver_name = "tty3270";
1810 driver->name = "ttyTUB"; 1826 driver->name = "3270/tty";
1811 driver->major = IBM_TTY3270_MAJOR; 1827 driver->major = IBM_TTY3270_MAJOR;
1812 driver->minor_start = RAW3270_FIRSTMINOR; 1828 driver->minor_start = 0;
1813 driver->type = TTY_DRIVER_TYPE_SYSTEM; 1829 driver->type = TTY_DRIVER_TYPE_SYSTEM;
1814 driver->subtype = SYSTEM_TYPE_TTY; 1830 driver->subtype = SYSTEM_TYPE_TTY;
1815 driver->init_termios = tty_std_termios; 1831 driver->init_termios = tty_std_termios;
1816 driver->flags = TTY_DRIVER_RESET_TERMIOS;
1817 tty_set_operations(driver, &tty3270_ops); 1832 tty_set_operations(driver, &tty3270_ops);
1818 ret = tty_register_driver(driver); 1833 ret = tty_register_driver(driver);
1819 if (ret) { 1834 if (ret) {
@@ -1821,6 +1836,7 @@ static int __init tty3270_init(void)
1821 return ret; 1836 return ret;
1822 } 1837 }
1823 tty3270_driver = driver; 1838 tty3270_driver = driver;
1839 raw3270_register_notifier(&tty3270_notifier);
1824 return 0; 1840 return 0;
1825} 1841}
1826 1842
@@ -1829,6 +1845,7 @@ tty3270_exit(void)
1829{ 1845{
1830 struct tty_driver *driver; 1846 struct tty_driver *driver;
1831 1847
1848 raw3270_unregister_notifier(&tty3270_notifier);
1832 driver = tty3270_driver; 1849 driver = tty3270_driver;
1833 tty3270_driver = NULL; 1850 tty3270_driver = NULL;
1834 tty_unregister_driver(driver); 1851 tty_unregister_driver(driver);