mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	ShellPkg/Connect: Simplify error handling in ShellConnectFromDevPaths()
In an effort to simplify the code in the ShellPkg, simplify error handling case in ShellConnectFromDevPaths(). No functional change is introduced. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This commit is contained in:
		 Pierre Gondois
					Pierre Gondois
				
			
				
					committed by
					
						 pierregondois
						pierregondois
					
				
			
			
				
	
			
			
			 pierregondois
						pierregondois
					
				
			
						parent
						
							7ae7bd8ef2
						
					
				
				
					commit
					bcfbaf5f00
				
			| @ -262,59 +262,11 @@ ShellConnectFromDevPaths ( | ||||
|     // | ||||
|     // connect short form device path | ||||
|     // | ||||
|     if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) && | ||||
|         (  (DevicePathSubType (Instance) == MSG_USB_CLASS_DP) | ||||
|         || (DevicePathSubType (Instance) == MSG_USB_WWID_DP) | ||||
|         )) | ||||
|     if (!((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) && | ||||
|           (  (DevicePathSubType (Instance) == MSG_USB_CLASS_DP) | ||||
|           || (DevicePathSubType (Instance) == MSG_USB_WWID_DP) | ||||
|           ))) | ||||
|     { | ||||
|       Status = ShellConnectPciRootBridge (); | ||||
|       if (EFI_ERROR (Status)) { | ||||
|         FreePool (Instance); | ||||
|         FreePool (DevPath); | ||||
|         return Status; | ||||
|       } | ||||
|  | ||||
|       Status = gBS->LocateHandleBuffer ( | ||||
|                       ByProtocol, | ||||
|                       &gEfiPciIoProtocolGuid, | ||||
|                       NULL, | ||||
|                       &HandleArrayCount, | ||||
|                       &HandleArray | ||||
|                       ); | ||||
|  | ||||
|       if (!EFI_ERROR (Status)) { | ||||
|         for (Index = 0; Index < HandleArrayCount; Index++) { | ||||
|           Status = gBS->HandleProtocol ( | ||||
|                           HandleArray[Index], | ||||
|                           &gEfiPciIoProtocolGuid, | ||||
|                           (VOID **)&PciIo | ||||
|                           ); | ||||
|  | ||||
|           if (!EFI_ERROR (Status)) { | ||||
|             Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class); | ||||
|             if (!EFI_ERROR (Status)) { | ||||
|               if ((PCI_CLASS_SERIAL == Class[2]) && | ||||
|                   (PCI_CLASS_SERIAL_USB == Class[1])) | ||||
|               { | ||||
|                 Status = gBS->ConnectController ( | ||||
|                                 HandleArray[Index], | ||||
|                                 NULL, | ||||
|                                 Instance, | ||||
|                                 FALSE | ||||
|                                 ); | ||||
|                 if (!EFI_ERROR (Status)) { | ||||
|                   AtLeastOneConnected = TRUE; | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       if (HandleArray != NULL) { | ||||
|         FreePool (HandleArray); | ||||
|       } | ||||
|     } else { | ||||
|       // | ||||
|       // connect the entire device path | ||||
|       // | ||||
| @ -322,6 +274,57 @@ ShellConnectFromDevPaths ( | ||||
|       if (!EFI_ERROR (Status)) { | ||||
|         AtLeastOneConnected = TRUE; | ||||
|       } | ||||
|  | ||||
|       FreePool (Instance); | ||||
|       continue; | ||||
|     } | ||||
|  | ||||
|     Status = ShellConnectPciRootBridge (); | ||||
|     if (EFI_ERROR (Status)) { | ||||
|       FreePool (Instance); | ||||
|       FreePool (DevPath); | ||||
|       return Status; | ||||
|     } | ||||
|  | ||||
|     Status = gBS->LocateHandleBuffer ( | ||||
|                     ByProtocol, | ||||
|                     &gEfiPciIoProtocolGuid, | ||||
|                     NULL, | ||||
|                     &HandleArrayCount, | ||||
|                     &HandleArray | ||||
|                     ); | ||||
|  | ||||
|     if (!EFI_ERROR (Status)) { | ||||
|       for (Index = 0; Index < HandleArrayCount; Index++) { | ||||
|         Status = gBS->HandleProtocol ( | ||||
|                         HandleArray[Index], | ||||
|                         &gEfiPciIoProtocolGuid, | ||||
|                         (VOID **)&PciIo | ||||
|                         ); | ||||
|  | ||||
|         if (!EFI_ERROR (Status)) { | ||||
|           Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class); | ||||
|           if (!EFI_ERROR (Status)) { | ||||
|             if ((PCI_CLASS_SERIAL == Class[2]) && | ||||
|                 (PCI_CLASS_SERIAL_USB == Class[1])) | ||||
|             { | ||||
|               Status = gBS->ConnectController ( | ||||
|                               HandleArray[Index], | ||||
|                               NULL, | ||||
|                               Instance, | ||||
|                               FALSE | ||||
|                               ); | ||||
|               if (!EFI_ERROR (Status)) { | ||||
|                 AtLeastOneConnected = TRUE; | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (HandleArray != NULL) { | ||||
|       FreePool (HandleArray); | ||||
|     } | ||||
|  | ||||
|     FreePool (Instance); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user