diff options
author | Tian, Feng <feng.tian@intel.com> | 2014-04-10 02:33:16 +0000 |
---|---|---|
committer | erictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-04-10 02:33:16 +0000 |
commit | 9161fd374fa8f26f1c330c94a0e0572718d72807 (patch) | |
tree | 04cf0558ce5b0f494a033164f93382b21e9a6430 | |
parent | 796fe92c8e53e71cf85e21288acc8c1ad5adb76b (diff) | |
download | edk2-9161fd374fa8f26f1c330c94a0e0572718d72807.tar.gz |
Revert r15444 check-in.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tian, Feng <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2014@15446 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 14 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c | 81 |
2 files changed, 63 insertions, 32 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index 9f99650703..9e0343da69 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c @@ -2,7 +2,7 @@ Implementation of the command set of USB Mass Storage Specification
for Bootability, Revision 1.0.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2012, 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
@@ -629,18 +629,6 @@ UsbBootGetParams ( }
//
- // According to USB Mass Storage Specification for Bootability, only following
- // 4 Peripheral Device Types are in spec.
- //
- if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) &&
- (UsbMass->Pdt != USB_PDT_CDROM) &&
- (UsbMass->Pdt != USB_PDT_OPTICAL) &&
- (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {
- DEBUG ((EFI_D_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));
- return EFI_UNSUPPORTED;
- }
-
- //
// Don't use the Removable bit in inquiry data to test whether the media
// is removable because many flash disks wrongly set this bit.
//
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c index be11cc78fe..4cbedfade6 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c @@ -1,7 +1,7 @@ /** @file
USB Mass Storage Driver that manages USB Mass Storage Device and produces Block I/O Protocol.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2011, 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
@@ -464,7 +464,8 @@ ON_EXIT: @param MaxLun The max LUN number.
@retval EFI_SUCCESS At least one LUN is initialized successfully.
- @retval EFI_NOT_FOUND Fail to initialize any of multiple LUNs.
+ @retval EFI_OUT_OF_RESOURCES Out of resource while creating device path node.
+ @retval Other Initialization fails.
**/
EFI_STATUS
@@ -482,10 +483,8 @@ UsbMassInitMultiLun ( DEVICE_LOGICAL_UNIT_DEVICE_PATH LunNode;
UINT8 Index;
EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
ASSERT (MaxLun > 0);
- ReturnStatus = EFI_NOT_FOUND;
for (Index = 0; Index <= MaxLun; Index++) {
@@ -511,10 +510,21 @@ UsbMassInitMultiLun ( // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.
//
Status = UsbMassInitMedia (UsbMass);
- if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // According to USB Mass Storage Specification for Bootability, only following
+ // 4 Peripheral Device Types are in spec.
+ //
+ if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) &&
+ (UsbMass->Pdt != USB_PDT_CDROM) &&
+ (UsbMass->Pdt != USB_PDT_OPTICAL) &&
+ (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {
+ DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));
+ goto ON_ERROR;
+ }
+ } else if (Status != EFI_NO_MEDIA){
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: UsbMassInitMedia (%r)\n", Status));
- FreePool (UsbMass);
- continue;
+ goto ON_ERROR;
}
//
@@ -530,9 +540,9 @@ UsbMassInitMultiLun ( if (UsbMass->DevicePath == NULL) {
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: failed to create device logic unit device path\n"));
+
Status = EFI_OUT_OF_RESOURCES;
- FreePool (UsbMass);
- continue;
+ goto ON_ERROR;
}
InitializeDiskInfo (UsbMass);
@@ -553,9 +563,7 @@ UsbMassInitMultiLun ( if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: InstallMultipleProtocolInterfaces (%r)\n", Status));
- FreePool (UsbMass->DevicePath);
- FreePool (UsbMass);
- continue;
+ goto ON_ERROR;
}
//
@@ -582,15 +590,38 @@ UsbMassInitMultiLun ( &UsbMass->DiskInfo,
NULL
);
- FreePool (UsbMass->DevicePath);
- FreePool (UsbMass);
- continue;
+ goto ON_ERROR;
}
- ReturnStatus = EFI_SUCCESS;
+
DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index));
}
- return ReturnStatus;
+ return EFI_SUCCESS;
+
+ON_ERROR:
+ if (UsbMass != NULL) {
+ if (UsbMass->DevicePath != NULL) {
+ FreePool (UsbMass->DevicePath);
+ }
+ FreePool (UsbMass);
+ }
+ if (UsbIo != NULL) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ UsbMass->Controller
+ );
+ }
+
+ //
+ // Return EFI_SUCCESS if at least one LUN is initialized successfully.
+ //
+ if (Index > 0) {
+ return EFI_SUCCESS;
+ } else {
+ return Status;
+ }
}
/**
@@ -651,7 +682,19 @@ UsbMassInitNonLun ( // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.
//
Status = UsbMassInitMedia (UsbMass);
- if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) {
+ if (!EFI_ERROR (Status)) {
+ //
+ // According to USB Mass Storage Specification for Bootability, only following
+ // 4 Peripheral Device Types are in spec.
+ //
+ if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) &&
+ (UsbMass->Pdt != USB_PDT_CDROM) &&
+ (UsbMass->Pdt != USB_PDT_OPTICAL) &&
+ (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {
+ DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));
+ goto ON_ERROR;
+ }
+ } else if (Status != EFI_NO_MEDIA){
DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: UsbMassInitMedia (%r)\n", Status));
goto ON_ERROR;
}
@@ -858,7 +901,7 @@ USBMassDriverBindingStart ( }
//
- // Initialize data for device that supports multiple LUNs.
+ // Initialize data for device that supports multiple LUNSs.
// EFI_SUCCESS is returned if at least 1 LUN is initialized successfully.
//
Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);
|