diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-08-07 15:47:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-13 19:50:20 -0400 |
commit | 16a1065f2113b2c068ea108a681fb6b1f3a02ce0 (patch) | |
tree | fd98208580a15288f1f5f38ff45489a9726f2af6 /drivers/char | |
parent | 737586fe51e6d0031f83d781c0cb2f3abf8caada (diff) |
TTY: synclink_cs, use dynamic tty devices
This allows us to provide the tty layer with information about
tty_port for each link. And it also allows us to get rid of the
remove_device loop in synclink_cs_exit because we had to reorder
pcmcia and tty driver registration in init. This was because we need
to have serial_driver initialized when calling
tty_port_register_device from pcmcia ->probe.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 0606586e76ab..ce277f74bd10 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -2731,6 +2731,8 @@ static void mgslpc_add_device(MGSLPC_INFO *info) | |||
2731 | #if SYNCLINK_GENERIC_HDLC | 2731 | #if SYNCLINK_GENERIC_HDLC |
2732 | hdlcdev_init(info); | 2732 | hdlcdev_init(info); |
2733 | #endif | 2733 | #endif |
2734 | tty_port_register_device(&info->port, serial_driver, info->line, | ||
2735 | &info->p_dev.dev); | ||
2734 | } | 2736 | } |
2735 | 2737 | ||
2736 | static void mgslpc_remove_device(MGSLPC_INFO *remove_info) | 2738 | static void mgslpc_remove_device(MGSLPC_INFO *remove_info) |
@@ -2744,6 +2746,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info) | |||
2744 | last->next_device = info->next_device; | 2746 | last->next_device = info->next_device; |
2745 | else | 2747 | else |
2746 | mgslpc_device_list = info->next_device; | 2748 | mgslpc_device_list = info->next_device; |
2749 | tty_unregister_device(serial_driver, info->line); | ||
2747 | #if SYNCLINK_GENERIC_HDLC | 2750 | #if SYNCLINK_GENERIC_HDLC |
2748 | hdlcdev_exit(info); | 2751 | hdlcdev_exit(info); |
2749 | #endif | 2752 | #endif |
@@ -2807,13 +2810,12 @@ static int __init synclink_cs_init(void) | |||
2807 | BREAKPOINT(); | 2810 | BREAKPOINT(); |
2808 | } | 2811 | } |
2809 | 2812 | ||
2810 | if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) | 2813 | serial_driver = tty_alloc_driver(MAX_DEVICE_COUNT, |
2811 | return rc; | 2814 | TTY_DRIVER_REAL_RAW | |
2812 | 2815 | TTY_DRIVER_DYNAMIC_DEV); | |
2813 | serial_driver = alloc_tty_driver(MAX_DEVICE_COUNT); | ||
2814 | if (!serial_driver) { | 2816 | if (!serial_driver) { |
2815 | rc = -ENOMEM; | 2817 | rc = -ENOMEM; |
2816 | goto err_pcmcia_drv; | 2818 | goto err; |
2817 | } | 2819 | } |
2818 | 2820 | ||
2819 | /* Initialize the tty_driver structure */ | 2821 | /* Initialize the tty_driver structure */ |
@@ -2827,7 +2829,6 @@ static int __init synclink_cs_init(void) | |||
2827 | serial_driver->init_termios = tty_std_termios; | 2829 | serial_driver->init_termios = tty_std_termios; |
2828 | serial_driver->init_termios.c_cflag = | 2830 | serial_driver->init_termios.c_cflag = |
2829 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 2831 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
2830 | serial_driver->flags = TTY_DRIVER_REAL_RAW; | ||
2831 | tty_set_operations(serial_driver, &mgslpc_ops); | 2832 | tty_set_operations(serial_driver, &mgslpc_ops); |
2832 | 2833 | ||
2833 | if ((rc = tty_register_driver(serial_driver)) < 0) { | 2834 | if ((rc = tty_register_driver(serial_driver)) < 0) { |
@@ -2836,26 +2837,28 @@ static int __init synclink_cs_init(void) | |||
2836 | goto err_put_tty; | 2837 | goto err_put_tty; |
2837 | } | 2838 | } |
2838 | 2839 | ||
2840 | rc = pcmcia_register_driver(&mgslpc_driver); | ||
2841 | if (rc < 0) | ||
2842 | goto err_unreg_tty; | ||
2843 | |||
2839 | printk("%s %s, tty major#%d\n", | 2844 | printk("%s %s, tty major#%d\n", |
2840 | driver_name, driver_version, | 2845 | driver_name, driver_version, |
2841 | serial_driver->major); | 2846 | serial_driver->major); |
2842 | 2847 | ||
2843 | return 0; | 2848 | return 0; |
2849 | err_unreg_tty: | ||
2850 | tty_unregister_driver(serial_driver); | ||
2844 | err_put_tty: | 2851 | err_put_tty: |
2845 | put_tty_driver(serial_driver); | 2852 | put_tty_driver(serial_driver); |
2846 | err_pcmcia_drv: | 2853 | err: |
2847 | pcmcia_unregister_driver(&mgslpc_driver); | ||
2848 | return rc; | 2854 | return rc; |
2849 | } | 2855 | } |
2850 | 2856 | ||
2851 | static void __exit synclink_cs_exit(void) | 2857 | static void __exit synclink_cs_exit(void) |
2852 | { | 2858 | { |
2853 | while (mgslpc_device_list) | 2859 | pcmcia_unregister_driver(&mgslpc_driver); |
2854 | mgslpc_remove_device(mgslpc_device_list); | ||
2855 | |||
2856 | tty_unregister_driver(serial_driver); | 2860 | tty_unregister_driver(serial_driver); |
2857 | put_tty_driver(serial_driver); | 2861 | put_tty_driver(serial_driver); |
2858 | pcmcia_unregister_driver(&mgslpc_driver); | ||
2859 | } | 2862 | } |
2860 | 2863 | ||
2861 | module_init(synclink_cs_init); | 2864 | module_init(synclink_cs_init); |