[IPoIB] Add unload handler and call CL_INIT from DriverEntry and CL_DEINIT
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 06:13:56 +0000 (06:13 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 06:13:56 +0000 (06:13 +0000)
from the unload handler.  Eliminates need for recursive CL_INIT and CL_DEINIT
support.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@71 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_driver.c

index f999084..b183747 100644 (file)
@@ -35,7 +35,6 @@
 #include "ipoib_port.h"\r
 #include "ipoib_driver.h"\r
 #include "ipoib_debug.h"\r
-#include <complib/cl_init.h>\r
 \r
 \r
 #define ITEM_POOL_START                16\r
@@ -131,17 +130,9 @@ ipoib_create_adapter(
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
-       if( !NT_SUCCESS( CL_INIT ) )\r
-       {\r
-               IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,\r
-                       ("cl_init failed.\n") );\r
-               return IB_ERROR;\r
-       }\r
-\r
        p_adapter = cl_zalloc( sizeof(ipoib_adapter_t) );\r
        if( !p_adapter )\r
        {\r
-               CL_DEINIT;\r
                IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, \r
                        ("Failed to allocate ipoib_adapter_t (%d bytes)",\r
                        sizeof(ipoib_adapter_t)) );\r
@@ -475,8 +466,6 @@ __adapter_free(
 \r
        cl_free( p_adapter );\r
 \r
-       CL_DEINIT;\r
-\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
 \r
index f81da08..26ac359 100644 (file)
@@ -34,6 +34,7 @@
 #include "ipoib_debug.h"\r
 #include "ipoib_port.h"\r
 #include <complib/cl_bus_ifc.h>\r
+#include <complib/cl_init.h>\r
 #include <initguid.h>\r
 #include <iba/ipoib_ifc.h>\r
 \r
@@ -128,6 +129,10 @@ DriverEntry(
        IN                              PDRIVER_OBJECT                          p_drv_obj,\r
        IN                              PUNICODE_STRING                         p_reg_path );\r
 \r
+VOID\r
+ipoib_unload(\r
+       IN                              PDRIVER_OBJECT                          p_drv_obj );\r
+\r
 NDIS_STATUS\r
 ipoib_initialize(\r
                OUT                     PNDIS_STATUS                            p_open_err_status,\r
@@ -246,6 +251,14 @@ DriverEntry(
        PAGED_CODE();\r
 #endif\r
 \r
+       status = CL_INIT;\r
+       if( !NT_SUCCESS( status ) )\r
+       {\r
+               IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,\r
+                       ("cl_init failed.\n") );\r
+               return status;\r
+       }\r
+\r
        status          = NDIS_STATUS_SUCCESS;\r
        ndis_handle     = NULL;\r
 \r
@@ -277,8 +290,13 @@ DriverEntry(
        if( status != NDIS_STATUS_SUCCESS )\r
        {\r
                IPOIB_TRACE( IPOIB_DBG_ERROR, \r
-                       ("NdisMRegisterMiniport failed with status of %s", status) );\r
+                       ("NdisMRegisterMiniport failed with status of %d\n", status) );\r
                NdisTerminateWrapper( ndis_handle, NULL );\r
+               CL_DEINIT;\r
+       }\r
+       else\r
+       {\r
+               NdisMRegisterUnloadHandler( ndis_handle, ipoib_unload );\r
        }\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
@@ -286,6 +304,17 @@ DriverEntry(
 }\r
 \r
 \r
+VOID\r
+ipoib_unload(\r
+       IN                              PDRIVER_OBJECT                          p_drv_obj )\r
+{\r
+       IPOIB_ENTER( IPOIB_DBG_INIT );\r
+       UNREFERENCED_PARAMETER( p_drv_obj );\r
+       CL_DEINIT;\r
+       IPOIB_EXIT( IPOIB_DBG_INIT );\r
+}\r
+\r
+\r
 NDIS_STATUS\r
 ipoib_get_adapter_params(\r
        IN                              NDIS_HANDLE* const                      wrapper_config_context,\r