From 7d618b4b680dd9caa1cac0d07b2caae07256590d Mon Sep 17 00:00:00 2001 From: ftillier Date: Mon, 19 Sep 2005 06:13:56 +0000 Subject: [PATCH] [IPoIB] Add unload handler and call CL_INIT from DriverEntry and CL_DEINIT 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 | 11 ----------- ulp/ipoib/kernel/ipoib_driver.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/ulp/ipoib/kernel/ipoib_adapter.c b/ulp/ipoib/kernel/ipoib_adapter.c index f999084a..b1837474 100644 --- a/ulp/ipoib/kernel/ipoib_adapter.c +++ b/ulp/ipoib/kernel/ipoib_adapter.c @@ -35,7 +35,6 @@ #include "ipoib_port.h" #include "ipoib_driver.h" #include "ipoib_debug.h" -#include #define ITEM_POOL_START 16 @@ -131,17 +130,9 @@ ipoib_create_adapter( IPOIB_ENTER( IPOIB_DBG_INIT ); - if( !NT_SUCCESS( CL_INIT ) ) - { - IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, - ("cl_init failed.\n") ); - return IB_ERROR; - } - p_adapter = cl_zalloc( sizeof(ipoib_adapter_t) ); if( !p_adapter ) { - CL_DEINIT; IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, ("Failed to allocate ipoib_adapter_t (%d bytes)", sizeof(ipoib_adapter_t)) ); @@ -475,8 +466,6 @@ __adapter_free( cl_free( p_adapter ); - CL_DEINIT; - IPOIB_EXIT( IPOIB_DBG_INIT ); } diff --git a/ulp/ipoib/kernel/ipoib_driver.c b/ulp/ipoib/kernel/ipoib_driver.c index f81da084..26ac3592 100644 --- a/ulp/ipoib/kernel/ipoib_driver.c +++ b/ulp/ipoib/kernel/ipoib_driver.c @@ -34,6 +34,7 @@ #include "ipoib_debug.h" #include "ipoib_port.h" #include +#include #include #include @@ -128,6 +129,10 @@ DriverEntry( IN PDRIVER_OBJECT p_drv_obj, IN PUNICODE_STRING p_reg_path ); +VOID +ipoib_unload( + IN PDRIVER_OBJECT p_drv_obj ); + NDIS_STATUS ipoib_initialize( OUT PNDIS_STATUS p_open_err_status, @@ -246,6 +251,14 @@ DriverEntry( PAGED_CODE(); #endif + status = CL_INIT; + if( !NT_SUCCESS( status ) ) + { + IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR, + ("cl_init failed.\n") ); + return status; + } + status = NDIS_STATUS_SUCCESS; ndis_handle = NULL; @@ -277,8 +290,13 @@ DriverEntry( if( status != NDIS_STATUS_SUCCESS ) { IPOIB_TRACE( IPOIB_DBG_ERROR, - ("NdisMRegisterMiniport failed with status of %s", status) ); + ("NdisMRegisterMiniport failed with status of %d\n", status) ); NdisTerminateWrapper( ndis_handle, NULL ); + CL_DEINIT; + } + else + { + NdisMRegisterUnloadHandler( ndis_handle, ipoib_unload ); } IPOIB_EXIT( IPOIB_DBG_INIT ); @@ -286,6 +304,17 @@ DriverEntry( } +VOID +ipoib_unload( + IN PDRIVER_OBJECT p_drv_obj ) +{ + IPOIB_ENTER( IPOIB_DBG_INIT ); + UNREFERENCED_PARAMETER( p_drv_obj ); + CL_DEINIT; + IPOIB_EXIT( IPOIB_DBG_INIT ); +} + + NDIS_STATUS ipoib_get_adapter_params( IN NDIS_HANDLE* const wrapper_config_context, -- 2.17.1