]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UsbMassStorage: Don't send READ_CAPACITY to unsupported usb mass storage...
authorTian, Feng <feng.tian@intel.com>
Thu, 10 Apr 2014 02:45:32 +0000 (02:45 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 10 Apr 2014 02:45:32 +0000 (02:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tian, Feng <feng.tian@intel.com>
Reviewed-by: Zeng, Star <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15447 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c

index 9e0343da6918276648a39f037bf1622c75476e98..9f996507034f91cfd4486ea0b82034d650fe39d2 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of the command set of USB Mass Storage Specification\r
   for Bootability, Revision 1.0.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -628,6 +628,18 @@ UsbBootGetParams (
     return Status;\r
   }\r
 \r
+  //\r
+  // According to USB Mass Storage Specification for Bootability, only following\r
+  // 4 Peripheral Device Types are in spec.\r
+  //\r
+  if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) &&\r
+       (UsbMass->Pdt != USB_PDT_CDROM) &&\r
+       (UsbMass->Pdt != USB_PDT_OPTICAL) &&\r
+       (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {\r
+    DEBUG ((EFI_D_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   //\r
   // Don't use the Removable bit in inquiry data to test whether the media\r
   // is removable because many flash disks wrongly set this bit.\r
index 4cbedfade6caec49755982f504f5f2fe59f7d00b..be11cc78fefa77eba99fb4d76979c660ddee8085 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   USB Mass Storage Driver that manages USB Mass Storage Device and produces Block I/O Protocol.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -464,8 +464,7 @@ ON_EXIT:
   @param  MaxLun               The max LUN number.\r
 \r
   @retval EFI_SUCCESS          At least one LUN is initialized successfully.\r
-  @retval EFI_OUT_OF_RESOURCES Out of resource while creating device path node.\r
-  @retval Other                Initialization fails.\r
+  @retval EFI_NOT_FOUND        Fail to initialize any of multiple LUNs.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -483,8 +482,10 @@ UsbMassInitMultiLun (
   DEVICE_LOGICAL_UNIT_DEVICE_PATH  LunNode;\r
   UINT8                            Index;\r
   EFI_STATUS                       Status;\r
+  EFI_STATUS                       ReturnStatus;\r
 \r
   ASSERT (MaxLun > 0);\r
+  ReturnStatus = EFI_NOT_FOUND;\r
 \r
   for (Index = 0; Index <= MaxLun; Index++) { \r
 \r
@@ -510,21 +511,10 @@ UsbMassInitMultiLun (
     // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
     //\r
     Status = UsbMassInitMedia (UsbMass);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // According to USB Mass Storage Specification for Bootability, only following\r
-      // 4 Peripheral Device Types are in spec.\r
-      //\r
-      if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
-           (UsbMass->Pdt != USB_PDT_CDROM) &&\r
-           (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
-           (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {\r
-        DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));\r
-        goto ON_ERROR;\r
-      }\r
-    } else if (Status != EFI_NO_MEDIA){\r
+    if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) {\r
       DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: UsbMassInitMedia (%r)\n", Status));\r
-      goto ON_ERROR;\r
+      FreePool (UsbMass);\r
+      continue;\r
     }\r
 \r
     //\r
@@ -540,9 +530,9 @@ UsbMassInitMultiLun (
   \r
     if (UsbMass->DevicePath == NULL) {\r
       DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: failed to create device logic unit device path\n"));\r
-  \r
       Status = EFI_OUT_OF_RESOURCES;\r
-      goto ON_ERROR;\r
+      FreePool (UsbMass);\r
+      continue;\r
     }\r
 \r
     InitializeDiskInfo (UsbMass);\r
@@ -563,7 +553,9 @@ UsbMassInitMultiLun (
     \r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: InstallMultipleProtocolInterfaces (%r)\n", Status));\r
-      goto ON_ERROR;\r
+      FreePool (UsbMass->DevicePath);\r
+      FreePool (UsbMass);\r
+      continue;\r
     }\r
 \r
     //\r
@@ -590,38 +582,15 @@ UsbMassInitMultiLun (
              &UsbMass->DiskInfo,\r
              NULL\r
              );\r
-      goto ON_ERROR;\r
+      FreePool (UsbMass->DevicePath);\r
+      FreePool (UsbMass);\r
+      continue;\r
     }\r
-    \r
+    ReturnStatus = EFI_SUCCESS;\r
     DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index));\r
   }\r
   \r
-  return EFI_SUCCESS;\r
-\r
-ON_ERROR:\r
-  if (UsbMass != NULL) {\r
-    if (UsbMass->DevicePath != NULL) {\r
-      FreePool (UsbMass->DevicePath);\r
-    }\r
-    FreePool (UsbMass);\r
-  }\r
-  if (UsbIo != NULL) {\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiUsbIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           UsbMass->Controller\r
-           );\r
-  }\r
-\r
-  //\r
-  // Return EFI_SUCCESS if at least one LUN is initialized successfully.\r
-  //\r
-  if (Index > 0) {\r
-    return EFI_SUCCESS; \r
-  } else {\r
-    return Status;\r
-  } \r
+  return ReturnStatus;\r
 }\r
 \r
 /**\r
@@ -682,19 +651,7 @@ UsbMassInitNonLun (
   // Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
   //\r
   Status = UsbMassInitMedia (UsbMass);\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // According to USB Mass Storage Specification for Bootability, only following\r
-    // 4 Peripheral Device Types are in spec.\r
-    //\r
-    if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) && \r
-         (UsbMass->Pdt != USB_PDT_CDROM) &&\r
-         (UsbMass->Pdt != USB_PDT_OPTICAL) && \r
-         (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {\r
-      DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));\r
-      goto ON_ERROR;\r
-    }\r
-  } else if (Status != EFI_NO_MEDIA){\r
+  if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) {\r
     DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: UsbMassInitMedia (%r)\n", Status));\r
     goto ON_ERROR;\r
   }\r
@@ -901,7 +858,7 @@ USBMassDriverBindingStart (
     }\r
 \r
     //\r
-    // Initialize data for device that supports multiple LUNSs.\r
+    // Initialize data for device that supports multiple LUNs.\r
     // EFI_SUCCESS is returned if at least 1 LUN is initialized successfully.\r
     //\r
     Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);\r