diff options
author | Laszlo Ersek <lersek@redhat.com> | 2014-03-03 08:40:35 +0000 |
---|---|---|
committer | jljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-03-03 08:40:35 +0000 |
commit | 99a6dce3c2abd348bba7ae62e25488a2381369f7 (patch) | |
tree | bff068832063c0a68986b5272a497630f5c20435 /OvmfPkg/QemuVideoDxe | |
parent | 42d0cad751d610a8e6680ffd468fc40c970e96c0 (diff) | |
download | edk2-99a6dce3c2abd348bba7ae62e25488a2381369f7.tar.gz edk2-99a6dce3c2abd348bba7ae62e25488a2381369f7.tar.bz2 edk2-99a6dce3c2abd348bba7ae62e25488a2381369f7.zip |
OvmfPkg: QemuVideoDxe: disentangle UEFI driver model use in Stop()
A bus driver needs to pay attention whether its Stop() function is being
called on the "main" controller handle (NumberOfChildren == 0) or on the
child handles (NumberOfChildren > 0).
In QemuVideoDxe, all our resources are associated with the one child
handle (and the Private data structure) *except* the top-level PciIo
protocol reference. Be conscious of which mode Stop() is being called for.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15284 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/QemuVideoDxe')
-rw-r--r-- | OvmfPkg/QemuVideoDxe/Driver.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index 508e1acb10..48a788f6f8 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -454,8 +454,26 @@ QemuVideoControllerDriverStop ( EFI_STATUS Status;
QEMU_VIDEO_PRIVATE_DATA *Private;
+ if (NumberOfChildren == 0) {
+ //
+ // Close the PCI I/O Protocol
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return EFI_SUCCESS;
+ }
+
+ //
+ // free all resources for whose access we need the child handle, because the
+ // child handle is going away
+ //
+ ASSERT (NumberOfChildren == 1);
Status = gBS->OpenProtocol (
- Controller,
+ ChildHandleBuffer[0],
&gEfiGraphicsOutputProtocolGuid,
(VOID **) &GraphicsOutput,
This->DriverBindingHandle,
@@ -470,6 +488,7 @@ QemuVideoControllerDriverStop ( // Get our private context information
//
Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
+ ASSERT (Private->Handle == ChildHandleBuffer[0]);
QemuVideoGraphicsOutputDestructor (Private);
//
@@ -496,16 +515,6 @@ QemuVideoControllerDriverStop ( NULL
);
- //
- // Close the PCI I/O Protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
gBS->CloseProtocol (
Controller,
&gEfiPciIoProtocolGuid,
|