Dag,

The following changes the way IrDA is initialised in 2.4 kernels.
We still call irda_proto_init via sock_init().  However, the rest
of the IrDA init (via irda_init()) is called via the initcalls
mechanism, and, due to the link order this ensures that the random
bytes are initialised before use.

In the case of a module, we call irda_init() directly, which then
calls irda_proto_init before doing anything.  This preserves the
old order that the initialisation used to happen.

Also, this patch makes use of the module_init(), module_exit() and
__exit features of 2.4.

diff -ur orig/net/irda/af_irda.c linux/net/irda/af_irda.c
--- orig/net/irda/af_irda.c     Thu Apr 27 20:51:43 2000
+++ linux/net/irda/af_irda.c    Sat Jul 29 17:10:37 2000
@@ -2157,14 +2157,14 @@
  */
 void __init irda_proto_init(struct net_proto *pro)
 {
+       MESSAGE("IrDA (tm) Protocols for Linux-2.3 (Dag Brattli)\n");
+
        sock_register(&irda_family_ops);
 
        irda_packet_type.type = htons(ETH_P_IRDA);
-        dev_add_pack(&irda_packet_type);
+       dev_add_pack(&irda_packet_type);
 
        register_netdevice_notifier(&irda_dev_notifier);
-
-       irda_init();
 }
 
 /*
@@ -2173,17 +2173,12 @@
  *    Remove IrDA protocol layer
  *
  */
-#ifdef MODULE
-void irda_proto_cleanup(void)
+void __exit irda_proto_cleanup(void)
 {
        irda_packet_type.type = htons(ETH_P_IRDA);
-        dev_remove_pack(&irda_packet_type);
+       dev_remove_pack(&irda_packet_type);
+
+       unregister_netdevice_notifier(&irda_dev_notifier);
 
-        unregister_netdevice_notifier(&irda_dev_notifier);
-       
        sock_unregister(PF_IRDA);
-       irda_cleanup();
-       
-        return;
 }
-#endif /* MODULE */
diff -ur orig/net/irda/irmod.c linux/net/irda/irmod.c
--- orig/net/irda/irmod.c       Sat Jul 15 00:10:40 2000
+++ linux/net/irda/irmod.c      Sat Jul 29 17:11:05 2000
@@ -206,10 +206,11 @@
 EXPORT_SYMBOL(irtty_set_packet_mode);
 #endif
 
-int __init irda_init(void)
+static int __init irda_init(void)
 {
-       MESSAGE("IrDA (tm) Protocols for Linux-2.3 (Dag Brattli)\n");
-       
+#ifdef MODULE
+       irda_proto_init(NULL);  /* Called by net/socket.c when non-modular */
+#endif
        irlmp_init();
        irlap_init();
        
@@ -256,9 +257,10 @@
        return 0;
 }
 
-#ifdef MODULE
-void irda_cleanup(void)
+static void __exit irda_cleanup(void)
 {
+       irda_proto_cleanup();
+
        misc_deregister(&irda.dev);
 
 #ifdef CONFIG_SYSCTL
@@ -279,7 +281,6 @@
        /* Remove middle layer */
        irlmp_cleanup();
 }
-#endif /* MODULE */
 
 /*
  * Function irda_unlock (lock)
@@ -540,33 +541,9 @@
 #endif /* MODULE */
 }
 
-#ifdef MODULE
-
 MODULE_AUTHOR("Dag Brattli <[EMAIL PROTECTED]>");
 MODULE_DESCRIPTION("The Linux IrDA Protocol Subsystem"); 
 MODULE_PARM(irda_debug, "1l");
 
-/*
- * Function init_module (void)
- *
- *    Initialize the irda module
- *
- */
-int init_module(void) 
-{
-       irda_proto_init(NULL);
-
-       return 0;
-}
-
-/*
- * Function cleanup_module (void)
- *
- *    Cleanup the irda module
- *
- */
-void cleanup_module(void) 
-{
-       irda_proto_cleanup();
-}
-#endif /* MODULE */
+module_init(irda_init);
+module_exit(irda_cleanup);

   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [EMAIL PROTECTED]      --- ---
  | | | |   http://www.arm.linux.org.uk/~rmk/aboutme.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

_______________________________________________
Linux-IrDA mailing list  -  [EMAIL PROTECTED]
http://www4.pasta.cs.UiT.No/mailman/listinfo/linux-irda

Reply via email to