Bluetooth: Coding style cleanup from previous rfcomm_init bug fix
[pandora-kernel.git] / net / bluetooth / rfcomm / core.c
index e50566e..26af485 100644 (file)
@@ -2080,28 +2080,43 @@ static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL);
 /* ---- Initialization ---- */
 static int __init rfcomm_init(void)
 {
+       int err;
+
        l2cap_load();
 
        hci_register_cb(&rfcomm_cb);
 
        rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd");
        if (IS_ERR(rfcomm_thread)) {
-               hci_unregister_cb(&rfcomm_cb);
-               return PTR_ERR(rfcomm_thread);
+               err = PTR_ERR(rfcomm_thread);
+               goto unregister;
        }
 
        if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0)
                BT_ERR("Failed to create RFCOMM info file");
 
-       rfcomm_init_sockets();
+       err = rfcomm_init_ttys();
+       if (err < 0)
+               goto stop;
 
-#ifdef CONFIG_BT_RFCOMM_TTY
-       rfcomm_init_ttys();
-#endif
+       err = rfcomm_init_sockets();
+       if (err < 0)
+               goto cleanup;
 
        BT_INFO("RFCOMM ver %s", VERSION);
 
        return 0;
+
+cleanup:
+       rfcomm_cleanup_ttys();
+
+stop:
+       kthread_stop(rfcomm_thread);
+
+unregister:
+       hci_unregister_cb(&rfcomm_cb);
+
+       return err;
 }
 
 static void __exit rfcomm_exit(void)
@@ -2112,9 +2127,7 @@ static void __exit rfcomm_exit(void)
 
        kthread_stop(rfcomm_thread);
 
-#ifdef CONFIG_BT_RFCOMM_TTY
        rfcomm_cleanup_ttys();
-#endif
 
        rfcomm_cleanup_sockets();
 }