]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
MdeModulePkg: Fix typos in comments and variables
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpDriver.c
index af6b60c6193ecfc94cd728ef39200a6a909bb7bb..5718e4df249941c6985d95bf38c0d2cf953e4181 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of driver entry point and driver binding protocol.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 of the BSD License which accompanies this distribution.  The full\r
@@ -26,6 +26,52 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
   NULL\r
 };\r
 \r
+/**\r
+  Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
+  \r
+  @param[in]    Entry           The entry to be removed.\r
+  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
+\r
+  @retval EFI_SUCCESS           The entry has been removed successfully.\r
+  @retval Others                Fail to remove the entry.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MnpDestroyServiceDataEntry (\r
+  IN LIST_ENTRY         *Entry,\r
+  IN VOID               *Context\r
+  )\r
+{\r
+  MNP_SERVICE_DATA              *MnpServiceData;\r
+  \r
+  MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);\r
+  return MnpDestroyServiceData (MnpServiceData);\r
+}\r
+\r
+/**\r
+  Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
+  \r
+  @param[in]    Entry           The entry to be removed.\r
+  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
+\r
+  @retval EFI_SUCCESS           The entry has been removed successfully.\r
+  @retval Others                Fail to remove the entry.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MnpDestroyServiceChildEntry (\r
+  IN LIST_ENTRY         *Entry,\r
+  IN VOID               *Context\r
+  )\r
+{\r
+  MNP_SERVICE_DATA              *MnpServiceData;\r
+\r
+  MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);\r
+  return MnpDestroyServiceChild (MnpServiceData);\r
+}\r
+\r
 /**\r
   Test to see if this driver supports ControllerHandle. This service\r
   is called by the EFI boot service ConnectController(). In\r
@@ -276,8 +322,8 @@ MnpDriverBindingStop (
   EFI_VLAN_CONFIG_PROTOCOL      *VlanConfig;\r
   MNP_DEVICE_DATA               *MnpDeviceData;\r
   MNP_SERVICE_DATA              *MnpServiceData;\r
-  BOOLEAN                       AllChildrenStopped;\r
-  LIST_ENTRY                    *Entry;\r
+  LIST_ENTRY                    *List;\r
+  UINTN                         ListLength;\r
 \r
   //\r
   // Try to retrieve MNP service binding protocol from the ControllerHandle\r
@@ -317,10 +363,15 @@ MnpDriverBindingStop (
     //\r
     // Destroy all MNP service data\r
     //\r
-    while (!IsListEmpty (&MnpDeviceData->ServiceList)) {\r
-      Entry = GetFirstNode (&MnpDeviceData->ServiceList);\r
-      MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);\r
-      MnpDestroyServiceData (MnpServiceData);\r
+    List = &MnpDeviceData->ServiceList;\r
+    Status = NetDestroyLinkList (\r
+               List,\r
+               MnpDestroyServiceDataEntry,\r
+               NULL,\r
+               &ListLength\r
+               );\r
+    if (EFI_ERROR (Status) || ListLength !=0) {\r
+      return EFI_DEVICE_ERROR;\r
     }\r
 \r
     //\r
@@ -341,23 +392,24 @@ MnpDriverBindingStop (
     MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);\r
     FreePool (MnpDeviceData);\r
 \r
+    if (gMnpControllerNameTable != NULL) {\r
+      FreeUnicodeStringTable (gMnpControllerNameTable);\r
+      gMnpControllerNameTable = NULL;\r
+    }\r
     return EFI_SUCCESS;\r
   }\r
 \r
   //\r
   // Stop all MNP child\r
   //\r
-  AllChildrenStopped = TRUE;\r
-  NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {\r
-    MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);\r
-\r
-    Status = MnpDestroyServiceChild (MnpServiceData);\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
+  List = &MnpDeviceData->ServiceList;\r
+  Status = NetDestroyLinkList (\r
+             List,\r
+             MnpDestroyServiceChildEntry,\r
+             NULL,\r
+             &ListLength\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -376,7 +428,7 @@ MnpDriverBindingStop (
 \r
   @retval EFI_SUCCES                 The protocol was added to ChildHandle.\r
   @retval EFI_INVALID_PARAMETER      ChildHandle is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES       There are not enough resources availabe to\r
+  @retval EFI_OUT_OF_RESOURCES       There are not enough resources available to\r
                                      create the child.\r
   @retval Others                     The child handle was not created.\r
 \r
@@ -493,7 +545,7 @@ ErrorExit:
   @retval EFI_SUCCES             The protocol was removed from ChildHandle.\r
   @retval EFI_UNSUPPORTED        ChildHandle does not support the protocol that\r
                                  is being removed.\r
-  @retval EFI_INVALID_PARAMETER  ChildHandle is not a valid UEFI handle.\r
+  @retval EFI_INVALID_PARAMETER  ChildHandle is NULL.\r
   @retval EFI_ACCESS_DENIED      The protocol could not be removed from the\r
                                  ChildHandle because its services are being\r
                                  used.\r