summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
diff options
context:
space:
mode:
authorElvin Li <elvin.li@intel.com>2014-01-08 03:47:43 +0000
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-08 03:47:43 +0000
commit6f497f8f71fa1c38b0b0204ff06f1d6d8256d8f1 (patch)
treed79ff4277d78f8ac8e10b8bbfe54a4652a23f8c0 /MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
parent94caa81c35093b4e1b6fb043e1290f3ca24f8c2c (diff)
downloadedk2-platforms-6f497f8f71fa1c38b0b0204ff06f1d6d8256d8f1.tar.xz
Check if component name protocol exist, uninstall it when it really exists.
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
Diffstat (limited to 'MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c')
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
index 392ca2ade5..80314d0660 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
@@ -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 @@ I2cHostUnload (
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 @@ I2cHostUnload (
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