]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassBot.c
index ce252e60fc4ee2c020a8c4e19aba2c085a71bdac..55c239d33e3eda27be30f27f5e82e86691c329a6 100644 (file)
@@ -12,7 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //\r
 // Definition of USB BOT Transport Protocol\r
 //\r
-USB_MASS_TRANSPORT mUsbBotTransport = {\r
+USB_MASS_TRANSPORT  mUsbBotTransport = {\r
   USB_MASS_STORE_BOT,\r
   UsbBotInit,\r
   UsbBotExecCommand,\r
@@ -38,8 +38,8 @@ USB_MASS_TRANSPORT mUsbBotTransport = {
 **/\r
 EFI_STATUS\r
 UsbBotInit (\r
-  IN  EFI_USB_IO_PROTOCOL       *UsbIo,\r
-  OUT VOID                      **Context OPTIONAL\r
+  IN  EFI_USB_IO_PROTOCOL  *UsbIo,\r
+  OUT VOID                 **Context OPTIONAL\r
   )\r
 {\r
   USB_BOT_PROTOCOL              *UsbBot;\r
@@ -84,17 +84,17 @@ UsbBotInit (
     }\r
 \r
     if (USB_IS_IN_ENDPOINT (EndPoint.EndpointAddress) &&\r
-       (UsbBot->BulkInEndpoint == NULL)) {\r
-\r
-      UsbBot->BulkInEndpoint  = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1);\r
-      CopyMem(UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));\r
+        (UsbBot->BulkInEndpoint == NULL))\r
+    {\r
+      UsbBot->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1);\r
+      CopyMem (UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));\r
     }\r
 \r
     if (USB_IS_OUT_ENDPOINT (EndPoint.EndpointAddress) &&\r
-       (UsbBot->BulkOutEndpoint == NULL)) {\r
-\r
-      UsbBot->BulkOutEndpoint   = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1) + 1;\r
-      CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof(EndPoint));\r
+        (UsbBot->BulkOutEndpoint == NULL))\r
+    {\r
+      UsbBot->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1) + 1;\r
+      CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof (EndPoint));\r
     }\r
   }\r
 \r
@@ -145,19 +145,19 @@ ON_ERROR:
 **/\r
 EFI_STATUS\r
 UsbBotSendCommand (\r
-  IN USB_BOT_PROTOCOL         *UsbBot,\r
-  IN UINT8                    *Cmd,\r
-  IN UINT8                    CmdLen,\r
-  IN EFI_USB_DATA_DIRECTION   DataDir,\r
-  IN UINT32                   TransLen,\r
-  IN UINT8                    Lun\r
+  IN USB_BOT_PROTOCOL        *UsbBot,\r
+  IN UINT8                   *Cmd,\r
+  IN UINT8                   CmdLen,\r
+  IN EFI_USB_DATA_DIRECTION  DataDir,\r
+  IN UINT32                  TransLen,\r
+  IN UINT8                   Lun\r
   )\r
 {\r
-  USB_BOT_CBW               Cbw;\r
-  EFI_STATUS                Status;\r
-  UINT32                    Result;\r
-  UINTN                     DataLen;\r
-  UINTN                     Timeout;\r
+  USB_BOT_CBW  Cbw;\r
+  EFI_STATUS   Status;\r
+  UINT32       Result;\r
+  UINTN        DataLen;\r
+  UINTN        Timeout;\r
 \r
   ASSERT ((CmdLen > 0) && (CmdLen <= USB_BOT_MAX_CMDLEN));\r
 \r
@@ -167,7 +167,7 @@ UsbBotSendCommand (
   Cbw.Signature = USB_BOT_CBW_SIGNATURE;\r
   Cbw.Tag       = UsbBot->CbwTag;\r
   Cbw.DataLen   = TransLen;\r
-  Cbw.Flag      = (UINT8) ((DataDir == EfiUsbDataIn) ? BIT7 : 0);\r
+  Cbw.Flag      = (UINT8)((DataDir == EfiUsbDataIn) ? BIT7 : 0);\r
   Cbw.Lun       = Lun;\r
   Cbw.CmdLen    = CmdLen;\r
 \r
@@ -190,7 +190,7 @@ UsbBotSendCommand (
                             &Result\r
                             );\r
   if (EFI_ERROR (Status)) {\r
-    if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && DataDir == EfiUsbDataOut) {\r
+    if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && (DataDir == EfiUsbDataOut)) {\r
       //\r
       // Respond to Bulk-Out endpoint stall with a Reset Recovery,\r
       // according to section 5.3.1 of USB Mass Storage Class Bulk-Only Transport Spec, v1.0.\r
@@ -204,7 +204,6 @@ UsbBotSendCommand (
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Transfer the data between the device and host.\r
 \r
@@ -226,16 +225,16 @@ UsbBotSendCommand (
 **/\r
 EFI_STATUS\r
 UsbBotDataTransfer (\r
-  IN USB_BOT_PROTOCOL         *UsbBot,\r
-  IN EFI_USB_DATA_DIRECTION   DataDir,\r
-  IN OUT UINT8                *Data,\r
-  IN OUT UINTN                *TransLen,\r
-  IN UINT32                   Timeout\r
+  IN USB_BOT_PROTOCOL        *UsbBot,\r
+  IN EFI_USB_DATA_DIRECTION  DataDir,\r
+  IN OUT UINT8               *Data,\r
+  IN OUT UINTN               *TransLen,\r
+  IN UINT32                  Timeout\r
   )\r
 {\r
-  EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;\r
-  EFI_STATUS                  Status;\r
-  UINT32                      Result;\r
+  EFI_USB_ENDPOINT_DESCRIPTOR  *Endpoint;\r
+  EFI_STATUS                   Status;\r
+  UINT32                       Result;\r
 \r
   //\r
   // If no data to transfer, just return EFI_SUCCESS.\r
@@ -274,15 +273,15 @@ UsbBotDataTransfer (
     } else {\r
       DEBUG ((DEBUG_ERROR, "UsbBotDataTransfer: (%r)\n", Status));\r
     }\r
-    if(Status == EFI_TIMEOUT){\r
-      UsbBotResetDevice(UsbBot, FALSE);\r
+\r
+    if (Status == EFI_TIMEOUT) {\r
+      UsbBotResetDevice (UsbBot, FALSE);\r
     }\r
   }\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Get the command execution status from device.\r
 \r
@@ -304,19 +303,19 @@ UsbBotDataTransfer (
 **/\r
 EFI_STATUS\r
 UsbBotGetStatus (\r
-  IN  USB_BOT_PROTOCOL      *UsbBot,\r
-  IN  UINT32                TransLen,\r
-  OUT UINT8                 *CmdStatus\r
+  IN  USB_BOT_PROTOCOL  *UsbBot,\r
+  IN  UINT32            TransLen,\r
+  OUT UINT8             *CmdStatus\r
   )\r
 {\r
-  USB_BOT_CSW               Csw;\r
-  UINTN                     Len;\r
-  UINT8                     Endpoint;\r
-  EFI_STATUS                Status;\r
-  UINT32                    Result;\r
-  EFI_USB_IO_PROTOCOL       *UsbIo;\r
-  UINT32                    Index;\r
-  UINTN                     Timeout;\r
+  USB_BOT_CSW          Csw;\r
+  UINTN                Len;\r
+  UINT8                Endpoint;\r
+  EFI_STATUS           Status;\r
+  UINT32               Result;\r
+  EFI_USB_IO_PROTOCOL  *UsbIo;\r
+  UINT32               Index;\r
+  UINTN                Timeout;\r
 \r
   *CmdStatus = USB_BOT_COMMAND_ERROR;\r
   Status     = EFI_DEVICE_ERROR;\r
@@ -339,10 +338,11 @@ UsbBotGetStatus (
                       Timeout,\r
                       &Result\r
                       );\r
-    if (EFI_ERROR(Status)) {\r
+    if (EFI_ERROR (Status)) {\r
       if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) {\r
         UsbClearEndpointStall (UsbIo, Endpoint);\r
       }\r
+\r
       continue;\r
     }\r
 \r
@@ -361,15 +361,15 @@ UsbBotGetStatus (
       break;\r
     }\r
   }\r
+\r
   //\r
-  //The tag is increased even if there is an error.\r
+  // The tag is increased even if there is an error.\r
   //\r
   UsbBot->CbwTag++;\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Call the USB Mass Storage Class BOT protocol to issue\r
   the command/data/status circle to execute the commands.\r
@@ -402,13 +402,13 @@ UsbBotExecCommand (
   OUT UINT32                  *CmdStatus\r
   )\r
 {\r
-  USB_BOT_PROTOCOL          *UsbBot;\r
-  EFI_STATUS                Status;\r
-  UINTN                     TransLen;\r
-  UINT8                     Result;\r
+  USB_BOT_PROTOCOL  *UsbBot;\r
+  EFI_STATUS        Status;\r
+  UINTN             TransLen;\r
+  UINT8             Result;\r
 \r
-  *CmdStatus  = USB_MASS_CMD_FAIL;\r
-  UsbBot      = (USB_BOT_PROTOCOL *) Context;\r
+  *CmdStatus = USB_MASS_CMD_FAIL;\r
+  UsbBot     = (USB_BOT_PROTOCOL *)Context;\r
 \r
   //\r
   // Send the command to the device. Return immediately if device\r
@@ -425,7 +425,7 @@ UsbBotExecCommand (
   // failed. The host should attempt to receive the CSW no matter\r
   // whether it succeeds or fails.\r
   //\r
-  TransLen = (UINTN) DataLen;\r
+  TransLen = (UINTN)DataLen;\r
   UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout);\r
 \r
   //\r
@@ -444,7 +444,6 @@ UsbBotExecCommand (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Reset the USB mass storage device by BOT protocol.\r
 \r
@@ -459,8 +458,8 @@ UsbBotExecCommand (
 **/\r
 EFI_STATUS\r
 UsbBotResetDevice (\r
-  IN  VOID                    *Context,\r
-  IN  BOOLEAN                 ExtendedVerification\r
+  IN  VOID     *Context,\r
+  IN  BOOLEAN  ExtendedVerification\r
   )\r
 {\r
   USB_BOT_PROTOCOL        *UsbBot;\r
@@ -469,7 +468,7 @@ UsbBotResetDevice (
   UINT32                  Result;\r
   UINT32                  Timeout;\r
 \r
-  UsbBot = (USB_BOT_PROTOCOL *) Context;\r
+  UsbBot = (USB_BOT_PROTOCOL *)Context;\r
 \r
   if (ExtendedVerification) {\r
     //\r
@@ -522,7 +521,6 @@ UsbBotResetDevice (
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Get the max LUN (Logical Unit Number) of USB mass storage device.\r
 \r
@@ -536,8 +534,8 @@ UsbBotResetDevice (
 **/\r
 EFI_STATUS\r
 UsbBotGetMaxLun (\r
-  IN  VOID                    *Context,\r
-  OUT UINT8                   *MaxLun\r
+  IN  VOID   *Context,\r
+  OUT UINT8  *MaxLun\r
   )\r
 {\r
   USB_BOT_PROTOCOL        *UsbBot;\r
@@ -546,11 +544,11 @@ UsbBotGetMaxLun (
   UINT32                  Result;\r
   UINT32                  Timeout;\r
 \r
-  if (Context == NULL || MaxLun == NULL) {\r
+  if ((Context == NULL) || (MaxLun == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  UsbBot = (USB_BOT_PROTOCOL *) Context;\r
+  UsbBot = (USB_BOT_PROTOCOL *)Context;\r
 \r
   //\r
   // Issue a class specific Bulk-Only Mass Storage get max lun request.\r
@@ -568,11 +566,11 @@ UsbBotGetMaxLun (
                             &Request,\r
                             EfiUsbDataIn,\r
                             Timeout,\r
-                            (VOID *) MaxLun,\r
+                            (VOID *)MaxLun,\r
                             1,\r
                             &Result\r
                             );\r
-  if (EFI_ERROR (Status) || *MaxLun > USB_BOT_MAX_LUN) {\r
+  if (EFI_ERROR (Status) || (*MaxLun > USB_BOT_MAX_LUN)) {\r
     //\r
     // If the Get LUN request returns an error or the MaxLun is larger than\r
     // the maximum LUN value (0x0f) supported by the USB Mass Storage Class\r
@@ -598,7 +596,7 @@ UsbBotGetMaxLun (
 **/\r
 EFI_STATUS\r
 UsbBotCleanUp (\r
-  IN  VOID                    *Context\r
+  IN  VOID  *Context\r
   )\r
 {\r
   FreePool (Context);\r