]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassCbi.c
index d56254b77c8d406244c90e5cdc8bd2571665b9a5..44e377bb8f927be8e3778ad8e3caf57b8b7a9203 100644 (file)
@@ -4,8 +4,8 @@
   Notice: it is being obsoleted by the standard body in favor of the BOT\r
   (Bulk-Only Transport).\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2018, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "UsbMass.h"\r
-#include "UsbMassCbi.h"\r
 \r
 //\r
 // Definition of USB CBI0 Transport Protocol\r
@@ -146,13 +145,13 @@ UsbCbiInit (
   if (Context != NULL) {\r
     *Context = UsbCbi;\r
   } else {\r
-    gBS->FreePool (UsbCbi);\r
+    FreePool (UsbCbi);\r
   }\r
\r
+\r
   return EFI_SUCCESS;\r
 \r
 ON_ERROR:\r
-  gBS->FreePool (UsbCbi);\r
+  FreePool (UsbCbi);\r
   return Status;\r
 }\r
 \r
@@ -457,6 +456,7 @@ UsbCbiExecCommand (
   //\r
   Status = UsbCbiSendCommand (UsbCbi, Cmd, CmdLen, Timeout);\r
   if (EFI_ERROR (Status)) {\r
+    gBS->Stall(10 * USB_MASS_1_MILLISECOND);\r
     DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status));\r
     return Status;\r
   }\r
@@ -486,10 +486,12 @@ UsbCbiExecCommand (
     //\r
     // For UFI device, ASC and ASCQ are returned.\r
     //\r
-    if (Result.Type != 0) {\r
+    // Do not set the USB_MASS_CMD_FAIL for a request sense command\r
+    // as a bad result type doesn't mean a cmd failure\r
+    //\r
+    if (Result.Type != 0 && *(UINT8*)Cmd != 0x03) {\r
       *CmdStatus = USB_MASS_CMD_FAIL;\r
     }\r
-\r
   } else {\r
     //\r
     // Check page 27, CBI spec 1.1 for vaious reture status.\r
@@ -572,7 +574,7 @@ UsbCbiResetDevice (
   //\r
   Status = UsbCbiSendCommand (UsbCbi, ResetCmd, USB_CBI_RESET_CMD_LEN, Timeout);\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    return EFI_DEVICE_ERROR;\r
   }\r
 \r
   //\r
@@ -605,6 +607,6 @@ UsbCbiCleanUp (
   IN  VOID                   *Context\r
   )\r
 {\r
-  gBS->FreePool (Context);\r
+  FreePool (Context);\r
   return EFI_SUCCESS;\r
 }\r