Revision: 15058
          http://sourceforge.net/p/edk2/code/15058
Author:   li-elvin
Date:     2014-01-08 03:47:43 +0000 (Wed, 08 Jan 2014)
Log Message:
-----------
Check if component name protocol exist, uninstall it when it really exists.

Signed-off-by: Elvin Li <elvin...@intel.com>
Reviewed-by: Feng Tian <feng.t...@intel.com>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
    trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c

Modified: trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c     2014-01-07 11:20:14 UTC 
(rev 15057)
+++ trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c     2014-01-08 03:47:43 UTC 
(rev 15058)
@@ -2,7 +2,7 @@
   This file implements I2C IO Protocol which enables the user to manipulate a 
single 
   I2C device independent of the host controller and I2C design.
 
-  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2013 - 2014, 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 text of the license may be 
found at
@@ -1408,6 +1408,8 @@
   EFI_HANDLE                        *DeviceHandleBuffer;
   UINTN                             DeviceHandleCount;
   UINTN                             Index;
+  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;
+  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
 
   //
   // Get the list of all I2C Controller handles in the handle database.
@@ -1448,14 +1450,47 @@
                   gI2cBusDriverBinding.DriverBindingHandle,
                   &gEfiDriverBindingProtocolGuid,
                   &gI2cBusDriverBinding,
-                  &gEfiComponentNameProtocolGuid,
-                  &gI2cBusComponentName,
-                  &gEfiComponentName2ProtocolGuid,
-                  &gI2cBusComponentName2,
                   NULL
                   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Note we have to one by one uninstall the following protocols.
+  // It's because some of them are optionally installed based on
+  // the following PCD settings.
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
+  //
+  Status = gBS->HandleProtocol (
+                  gI2cBusDriverBinding.DriverBindingHandle,
+                  &gEfiComponentNameProtocolGuid,
+                  (VOID **) &ComponentName
+                  );
+  if (!EFI_ERROR (Status)) {
+    gBS->UninstallProtocolInterface (
+           gI2cBusDriverBinding.DriverBindingHandle,
+           &gEfiComponentNameProtocolGuid,
+           ComponentName
+           );
+  }
+
+  Status = gBS->HandleProtocol (
+                  gI2cBusDriverBinding.DriverBindingHandle,
+                  &gEfiComponentName2ProtocolGuid,
+                  (VOID **) &ComponentName2
+                  );
+  if (!EFI_ERROR (Status)) {
+    gBS->UninstallProtocolInterface (
+           gI2cBusDriverBinding.DriverBindingHandle,
+           &gEfiComponentName2ProtocolGuid,
+           ComponentName2
+           );
+  }
+
+  Status = EFI_SUCCESS;
+
 Done:
   //
   // Free the buffer containing the list of handles from the handle database

Modified: trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c    2014-01-07 11:20:14 UTC 
(rev 15057)
+++ trunk/edk2/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c    2014-01-08 03:47:43 UTC 
(rev 15058)
@@ -2,7 +2,7 @@
   This file implements I2C Host Protocol which provides callers with the 
ability to 
   do I/O transactions to all of the devices on the I2C bus.
 
-  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2013 - 2014, 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 text of the license may be 
found at
@@ -1131,6 +1131,8 @@
   EFI_HANDLE                        *DeviceHandleBuffer;
   UINTN                             DeviceHandleCount;
   UINTN                             Index;
+  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;
+  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
 
   //
   // Get the list of all I2C Controller handles in the handle database.
@@ -1171,14 +1173,47 @@
                   gI2cHostDriverBinding.DriverBindingHandle,
                   &gEfiDriverBindingProtocolGuid,
                   &gI2cHostDriverBinding,
-                  &gEfiComponentNameProtocolGuid,
-                  &gI2cHostComponentName,
-                  &gEfiComponentName2ProtocolGuid,
-                  &gI2cHostComponentName2,
                   NULL
                   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Note we have to one by one uninstall the following protocols.
+  // It's because some of them are optionally installed based on
+  // the following PCD settings.
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
+  //   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
+  //   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
+  //
+  Status = gBS->HandleProtocol (
+                  gI2cHostDriverBinding.DriverBindingHandle,
+                  &gEfiComponentNameProtocolGuid,
+                  (VOID **) &ComponentName
+                  );
+  if (!EFI_ERROR (Status)) {
+    gBS->UninstallProtocolInterface (
+           gI2cHostDriverBinding.DriverBindingHandle,
+           &gEfiComponentNameProtocolGuid,
+           ComponentName
+           );
+  }
+
+  Status = gBS->HandleProtocol (
+                  gI2cHostDriverBinding.DriverBindingHandle,
+                  &gEfiComponentName2ProtocolGuid,
+                  (VOID **) &ComponentName2
+                  );
+  if (!EFI_ERROR (Status)) {
+    gBS->UninstallProtocolInterface (
+           gI2cHostDriverBinding.DriverBindingHandle,
+           &gEfiComponentName2ProtocolGuid,
+           ComponentName2
+           );
+  }
+
+  Status = EFI_SUCCESS;
+
 Done:
   //
   // Free the buffer containing the list of handles from the handle database

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to