mirror of https://github.com/acidanthera/audk.git
Fix a bug that prevents Fat driver being unloaded successfully.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> (based on FatPkg commit 8e0e11897d92c75a6cd1d0fa8af8cb50a60bfe2d) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Acked-by: Mark Doran <mark.doran@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
bd10d0712f
commit
b6efb80ad0
|
@ -1,6 +1,6 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 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
|
||||
|
@ -140,6 +140,8 @@ Returns:
|
|||
EFI_HANDLE *DeviceHandleBuffer;
|
||||
UINTN DeviceHandleCount;
|
||||
UINTN Index;
|
||||
VOID *ComponentName;
|
||||
VOID *ComponentName2;
|
||||
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
|
@ -148,18 +150,75 @@ Returns:
|
|||
&DeviceHandleCount,
|
||||
&DeviceHandleBuffer
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (Index = 0; Index < DeviceHandleCount; Index++) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < DeviceHandleCount; Index++) {
|
||||
Status = EfiTestManagedDevice (DeviceHandleBuffer[Index], ImageHandle, &gEfiDiskIoProtocolGuid);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->DisconnectController (
|
||||
DeviceHandleBuffer[Index],
|
||||
ImageHandle,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == DeviceHandleCount) {
|
||||
//
|
||||
// Driver is stopped successfully.
|
||||
//
|
||||
Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentNameProtocolGuid, &ComponentName);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ComponentName = NULL;
|
||||
}
|
||||
|
||||
if (DeviceHandleBuffer != NULL) {
|
||||
FreePool (DeviceHandleBuffer);
|
||||
Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentName2ProtocolGuid, &ComponentName2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ComponentName2 = NULL;
|
||||
}
|
||||
|
||||
if (ComponentName == NULL) {
|
||||
if (ComponentName2 == NULL) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
|
||||
&gEfiComponentName2ProtocolGuid, ComponentName2,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (ComponentName2 == NULL) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
|
||||
&gEfiComponentNameProtocolGuid, ComponentName,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
|
||||
&gEfiComponentNameProtocolGuid, ComponentName,
|
||||
&gEfiComponentName2ProtocolGuid, ComponentName2,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DeviceHandleBuffer != NULL) {
|
||||
FreePool (DeviceHandleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
|
Loading…
Reference in New Issue