]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Check if component name protocol exist, uninstall it when it really exists.
authorElvin Li <elvin.li@intel.com>
Wed, 8 Jan 2014 03:47:43 +0000 (03:47 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 8 Jan 2014 03:47:43 +0000 (03:47 +0000)
Signed-off-by: Elvin Li <elvin.li@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15058 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c

index 3da1474edc009c8957d65a96ba708ee4c4d7369e..02c3a0e353f74702591f4235d8ec14a34958b435 100644 (file)
@@ -2,7 +2,7 @@
   This file implements I2C IO Protocol which enables the user to manipulate a single \r
   I2C device independent of the host controller and I2C design.\r
 \r
-  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1408,6 +1408,8 @@ I2cBusUnload (
   EFI_HANDLE                        *DeviceHandleBuffer;\r
   UINTN                             DeviceHandleCount;\r
   UINTN                             Index;\r
+  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;\r
+  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
 \r
   //\r
   // Get the list of all I2C Controller handles in the handle database.\r
@@ -1448,14 +1450,47 @@ I2cBusUnload (
                   gI2cBusDriverBinding.DriverBindingHandle,\r
                   &gEfiDriverBindingProtocolGuid,\r
                   &gI2cBusDriverBinding,\r
-                  &gEfiComponentNameProtocolGuid,\r
-                  &gI2cBusComponentName,\r
-                  &gEfiComponentName2ProtocolGuid,\r
-                  &gI2cBusComponentName2,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Note we have to one by one uninstall the following protocols.\r
+  // It's because some of them are optionally installed based on\r
+  // the following PCD settings.\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  gI2cBusDriverBinding.DriverBindingHandle,\r
+                  &gEfiComponentNameProtocolGuid,\r
+                  (VOID **) &ComponentName\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->UninstallProtocolInterface (\r
+           gI2cBusDriverBinding.DriverBindingHandle,\r
+           &gEfiComponentNameProtocolGuid,\r
+           ComponentName\r
+           );\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  gI2cBusDriverBinding.DriverBindingHandle,\r
+                  &gEfiComponentName2ProtocolGuid,\r
+                  (VOID **) &ComponentName2\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->UninstallProtocolInterface (\r
+           gI2cBusDriverBinding.DriverBindingHandle,\r
+           &gEfiComponentName2ProtocolGuid,\r
+           ComponentName2\r
+           );\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
 Done:\r
   //\r
   // Free the buffer containing the list of handles from the handle database\r
index 392ca2ade54f1f0e9d6dfb68436957b48ee8c79f..80314d0660a745fc8e480b58497c6e99edf62b0f 100644 (file)
@@ -2,7 +2,7 @@
   This file implements I2C Host Protocol which provides callers with the ability to \r
   do I/O transactions to all of the devices on the I2C bus.\r
 \r
-  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1131,6 +1131,8 @@ I2cHostUnload (
   EFI_HANDLE                        *DeviceHandleBuffer;\r
   UINTN                             DeviceHandleCount;\r
   UINTN                             Index;\r
+  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;\r
+  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
 \r
   //\r
   // Get the list of all I2C Controller handles in the handle database.\r
@@ -1171,14 +1173,47 @@ I2cHostUnload (
                   gI2cHostDriverBinding.DriverBindingHandle,\r
                   &gEfiDriverBindingProtocolGuid,\r
                   &gI2cHostDriverBinding,\r
-                  &gEfiComponentNameProtocolGuid,\r
-                  &gI2cHostComponentName,\r
-                  &gEfiComponentName2ProtocolGuid,\r
-                  &gI2cHostComponentName2,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Note we have to one by one uninstall the following protocols.\r
+  // It's because some of them are optionally installed based on\r
+  // the following PCD settings.\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable\r
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  gI2cHostDriverBinding.DriverBindingHandle,\r
+                  &gEfiComponentNameProtocolGuid,\r
+                  (VOID **) &ComponentName\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->UninstallProtocolInterface (\r
+           gI2cHostDriverBinding.DriverBindingHandle,\r
+           &gEfiComponentNameProtocolGuid,\r
+           ComponentName\r
+           );\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  gI2cHostDriverBinding.DriverBindingHandle,\r
+                  &gEfiComponentName2ProtocolGuid,\r
+                  (VOID **) &ComponentName2\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->UninstallProtocolInterface (\r
+           gI2cHostDriverBinding.DriverBindingHandle,\r
+           &gEfiComponentName2ProtocolGuid,\r
+           ComponentName2\r
+           );\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
 Done:\r
   //\r
   // Free the buffer containing the list of handles from the handle database\r