[openib-general] 2 questions on physical code layout

Roland Dreier roland at topspin.com
Mon Oct 25 11:18:40 PDT 2004


By the way, here's what the diff to the code to combine ib_mad and
ib_agent looks like (appropriate Makefile changes are also needed).

Index: linux-kernel/infiniband/core/ib_agent.c
===================================================================
--- linux-kernel.orig/infiniband/core/ib_agent.c	2004-10-24 21:28:25.000000000 -0700
+++ linux-kernel/infiniband/core/ib_agent.c	2004-10-25 11:11:46.000000000 -0700
@@ -837,26 +837,8 @@
 	return;
 }
 
-static struct ib_client ib_agent_client = {
+struct ib_client agent_client = {
         .name = "ib_agent",
         .add = ib_agent_init_device,
         .remove = ib_agent_remove_device
 };
-                                                                                
-static int __init ib_agent_init(void)
-{
-        if (ib_register_client(&ib_agent_client)) {
-                printk(KERN_ERR SPFX "Couldn't register ib_agent client\n");
-                return -EINVAL;
-        }
-                                                                                
-        return 0;
-}
-                                                                                
-static void __exit ib_agent_exit(void)
-{
-	ib_unregister_client(&ib_agent_client);
-}
-
-module_init(ib_agent_init);
-module_exit(ib_agent_exit);
Index: linux-kernel/infiniband/core/ib_mad.c
===================================================================
--- linux-kernel.orig/infiniband/core/ib_mad.c	2004-10-24 21:28:25.000000000 -0700
+++ linux-kernel/infiniband/core/ib_mad.c	2004-10-25 11:12:58.000000000 -0700
@@ -1999,6 +1999,8 @@
 	.remove = ib_mad_remove_device
 };
 
+extern struct ib_client agent_client;
+
 static int __init ib_mad_init_module(void)
 {
 	int ret;
@@ -2022,8 +2024,17 @@
 		ret = -EINVAL;
 		goto error2;
 	}
+
+	if (ib_register_client(&agent_client)) {
+		printk(KERN_ERR PFX "Couldn't register ib_agent client\n");
+		ret = -EINVAL;
+		goto error3;
+	}
+
 	return 0;
 
+error3:
+	ib_unregister_client(&mad_client);
 error2:
 	kmem_cache_destroy(ib_mad_cache);
 error1:
@@ -2032,6 +2043,7 @@
 
 static void __exit ib_mad_cleanup_module(void)
 {
+	ib_unregister_client(&agent_client);
 	ib_unregister_client(&mad_client);
 
 	if (kmem_cache_destroy(ib_mad_cache)) {



More information about the general mailing list