summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c')
-rw-r--r--MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c86
1 files changed, 68 insertions, 18 deletions
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
index 03ddfb7ccc..84c618c27d 100644
--- a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
+++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
@@ -1,7 +1,7 @@
/** @file
Implementation of driver entry point and driver binding protocol.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -27,6 +27,50 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
};
/**
+ Callback function which provided by user to remove one node in NetDestroyLinkList process.
+
+ @param[in] Entry The entry to be removed.
+ @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
+
+ @retval EFI_SUCCESS The entry has been removed successfully.
+ @retval Others Fail to remove the entry.
+
+**/
+EFI_STATUS
+MnpDestroyServiceDataEntry (
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
+)
+{
+ MNP_SERVICE_DATA *MnpServiceData;
+
+ MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
+ return MnpDestroyServiceData (MnpServiceData);
+}
+
+/**
+ Callback function which provided by user to remove one node in NetDestroyLinkList process.
+
+ @param[in] Entry The entry to be removed.
+ @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
+
+ @retval EFI_SUCCESS The entry has been removed successfully.
+ @retval Others Fail to remove the entry.
+
+**/
+EFI_STATUS
+MnpDestroyServiceChildEntry (
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
+)
+{
+ MNP_SERVICE_DATA *MnpServiceData;
+
+ MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
+ return MnpDestroyServiceChild (MnpServiceData);
+}
+
+/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
order to make drivers as small as possible, there are a few calling
@@ -276,8 +320,8 @@ MnpDriverBindingStop (
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
MNP_DEVICE_DATA *MnpDeviceData;
MNP_SERVICE_DATA *MnpServiceData;
- BOOLEAN AllChildrenStopped;
- LIST_ENTRY *Entry;
+ LIST_ENTRY *List;
+ UINTN ListLength;
//
// Try to retrieve MNP service binding protocol from the ControllerHandle
@@ -317,10 +361,15 @@ MnpDriverBindingStop (
//
// Destroy all MNP service data
//
- while (!IsListEmpty (&MnpDeviceData->ServiceList)) {
- Entry = GetFirstNode (&MnpDeviceData->ServiceList);
- MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
- MnpDestroyServiceData (MnpServiceData);
+ List = &MnpDeviceData->ServiceList;
+ Status = NetDestroyLinkList (
+ List,
+ MnpDestroyServiceDataEntry,
+ NULL,
+ &ListLength
+ );
+ if (EFI_ERROR (Status) || ListLength !=0) {
+ return EFI_DEVICE_ERROR;
}
//
@@ -341,23 +390,24 @@ MnpDriverBindingStop (
MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
FreePool (MnpDeviceData);
+ if (gMnpControllerNameTable != NULL) {
+ FreeUnicodeStringTable (gMnpControllerNameTable);
+ gMnpControllerNameTable = NULL;
+ }
return EFI_SUCCESS;
}
//
// Stop all MNP child
//
- AllChildrenStopped = TRUE;
- NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
- MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
-
- Status = MnpDestroyServiceChild (MnpServiceData);
- if (EFI_ERROR (Status)) {
- AllChildrenStopped = FALSE;
- }
- }
-
- if (!AllChildrenStopped) {
+ List = &MnpDeviceData->ServiceList;
+ Status = NetDestroyLinkList (
+ List,
+ MnpDestroyServiceChildEntry,
+ NULL,
+ &ListLength
+ );
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}