aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:47:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-13 19:50:20 -0400
commit737586fe51e6d0031f83d781c0cb2f3abf8caada (patch)
tree64efd975172e268ce12d3a92843dae175a623b10
parentb19e2ca77ee4becadc85341bb0c1cee454dd4fd5 (diff)
TTY: synclink_cs, sanitize fail paths
We will need to change the order of tty and pcmcia drivers initializations (see the reason later in this series). And the fail path handling is currently performed in a separate function that as well takes care of proper deinitialization in module_exit. It is hard to read and will need to be adjusted by our changes anyway. Instead, get rid of this helper function and do the fail paths handling directly in the init function. (And move the body of the function to module_exit.) 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>
-rw-r--r--drivers/char/pcmcia/synclink_cs.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index d0cbd29ecfd7..0606586e76ab 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2798,23 +2798,6 @@ static const struct tty_operations mgslpc_ops = {
2798 .proc_fops = &mgslpc_proc_fops, 2798 .proc_fops = &mgslpc_proc_fops,
2799}; 2799};
2800 2800
2801static void synclink_cs_cleanup(void)
2802{
2803 int rc;
2804
2805 while(mgslpc_device_list)
2806 mgslpc_remove_device(mgslpc_device_list);
2807
2808 if (serial_driver) {
2809 if ((rc = tty_unregister_driver(serial_driver)))
2810 printk("%s(%d) failed to unregister tty driver err=%d\n",
2811 __FILE__,__LINE__,rc);
2812 put_tty_driver(serial_driver);
2813 }
2814
2815 pcmcia_unregister_driver(&mgslpc_driver);
2816}
2817
2818static int __init synclink_cs_init(void) 2801static int __init synclink_cs_init(void)
2819{ 2802{
2820 int rc; 2803 int rc;
@@ -2830,7 +2813,7 @@ static int __init synclink_cs_init(void)
2830 serial_driver = alloc_tty_driver(MAX_DEVICE_COUNT); 2813 serial_driver = alloc_tty_driver(MAX_DEVICE_COUNT);
2831 if (!serial_driver) { 2814 if (!serial_driver) {
2832 rc = -ENOMEM; 2815 rc = -ENOMEM;
2833 goto error; 2816 goto err_pcmcia_drv;
2834 } 2817 }
2835 2818
2836 /* Initialize the tty_driver structure */ 2819 /* Initialize the tty_driver structure */
@@ -2850,25 +2833,29 @@ static int __init synclink_cs_init(void)
2850 if ((rc = tty_register_driver(serial_driver)) < 0) { 2833 if ((rc = tty_register_driver(serial_driver)) < 0) {
2851 printk("%s(%d):Couldn't register serial driver\n", 2834 printk("%s(%d):Couldn't register serial driver\n",
2852 __FILE__,__LINE__); 2835 __FILE__,__LINE__);
2853 put_tty_driver(serial_driver); 2836 goto err_put_tty;
2854 serial_driver = NULL;
2855 goto error;
2856 } 2837 }
2857 2838
2858 printk("%s %s, tty major#%d\n", 2839 printk("%s %s, tty major#%d\n",
2859 driver_name, driver_version, 2840 driver_name, driver_version,
2860 serial_driver->major); 2841 serial_driver->major);
2861 2842
2862 return 0; 2843 return 0;
2863 2844err_put_tty:
2864error: 2845 put_tty_driver(serial_driver);
2865 synclink_cs_cleanup(); 2846err_pcmcia_drv:
2866 return rc; 2847 pcmcia_unregister_driver(&mgslpc_driver);
2848 return rc;
2867} 2849}
2868 2850
2869static void __exit synclink_cs_exit(void) 2851static void __exit synclink_cs_exit(void)
2870{ 2852{
2871 synclink_cs_cleanup(); 2853 while (mgslpc_device_list)
2854 mgslpc_remove_device(mgslpc_device_list);
2855
2856 tty_unregister_driver(serial_driver);
2857 put_tty_driver(serial_driver);
2858 pcmcia_unregister_driver(&mgslpc_driver);
2872} 2859}
2873 2860
2874module_init(synclink_cs_init); 2861module_init(synclink_cs_init);