]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/Disk/Partition/Dxe/Partition.c
Fixed bug in partition driver:
[mirror_edk2.git] / EdkModulePkg / Universal / Disk / Partition / Dxe / Partition.c
index 504d98357fabee76023071c33b0112613ebdcee5..77cee2442b4ed64da73dfc7c7cbee6cd77db9ef5 100644 (file)
@@ -71,6 +71,15 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
   NULL\r
 };\r
 \r
+STATIC \r
+PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {\r
+  PartitionInstallGptChildHandles,\r
+  PartitionInstallElToritoChildHandles,\r
+  PartitionInstallMbrChildHandles,\r
+  NULL\r
+};\r
+\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 PartitionDriverBindingSupported (\r
@@ -212,6 +221,7 @@ PartitionDriverBindingStart (
   EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
   EFI_DISK_IO_PROTOCOL      *DiskIo;\r
   EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+  PARTITION_DETECT_ROUTINE  *Routine;\r
 \r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -269,32 +279,19 @@ PartitionDriverBindingStart (
     // media supports a given partition type install child handles to represent\r
     // the partitions described by the media.\r
     //\r
-    if (PartitionInstallGptChildHandles (\r
-          This,\r
-          ControllerHandle,\r
-          DiskIo,\r
-          BlockIo,\r
-          ParentDevicePath\r
-          ) ||\r
-\r
-    PartitionInstallElToritoChildHandles (\r
-          This,\r
-          ControllerHandle,\r
-          DiskIo,\r
-          BlockIo,\r
-          ParentDevicePath\r
-          ) ||\r
-\r
-    PartitionInstallMbrChildHandles (\r
-          This,\r
-          ControllerHandle,\r
-          DiskIo,\r
-          BlockIo,\r
-          ParentDevicePath\r
-          )) {\r
-      Status = EFI_SUCCESS;\r
-    } else {\r
-      Status = EFI_NOT_FOUND;\r
+    Routine = &mPartitionDetectRoutineTable[0];\r
+    while (*Routine != NULL) {\r
+      Status = (*Routine) (\r
+                   This,\r
+                   ControllerHandle,\r
+                   DiskIo,\r
+                   BlockIo,\r
+                   ParentDevicePath\r
+                   );\r
+      if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED) {\r
+        break;\r
+      }\r
+      Routine++;\r
     }\r
   }\r
   //\r
@@ -303,7 +300,7 @@ PartitionDriverBindingStart (
   // driver. So don't try to close them. Otherwise, we will break the dependency\r
   // between the controller and the driver set up before.\r
   //\r
-  if (EFI_ERROR (Status) && !EFI_ERROR (OpenStatus)) {\r
+  if (EFI_ERROR (Status) && !EFI_ERROR (OpenStatus) && Status != EFI_MEDIA_CHANGED) {\r
     gBS->CloseProtocol (\r
           ControllerHandle,\r
           &gEfiDiskIoProtocolGuid,\r