]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbEnumer.c
index 500978a9dedc818af46be9aa8f81a0fd3fbe3137..5495b324b381b9c36748faa4f689b307c26669a5 100644 (file)
@@ -20,13 +20,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/\r
 USB_ENDPOINT_DESC *\r
 UsbGetEndpointDesc (\r
-  IN USB_INTERFACE        *UsbIf,\r
-  IN UINT8                EpAddr\r
+  IN USB_INTERFACE  *UsbIf,\r
+  IN UINT8          EpAddr\r
   )\r
 {\r
-  USB_ENDPOINT_DESC       *EpDesc;\r
-  UINT8                   Index;\r
-  UINT8                   NumEndpoints;\r
+  USB_ENDPOINT_DESC  *EpDesc;\r
+  UINT8              Index;\r
+  UINT8              NumEndpoints;\r
 \r
   NumEndpoints = UsbIf->IfSetting->Desc.NumEndpoints;\r
 \r
@@ -41,7 +41,6 @@ UsbGetEndpointDesc (
   return NULL;\r
 }\r
 \r
-\r
 /**\r
   Free the resource used by USB interface.\r
 \r
@@ -52,31 +51,34 @@ UsbGetEndpointDesc (
 **/\r
 EFI_STATUS\r
 UsbFreeInterface (\r
-  IN USB_INTERFACE        *UsbIf\r
+  IN USB_INTERFACE  *UsbIf\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
+  EFI_STATUS  Status;\r
 \r
   UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);\r
 \r
   Status = gBS->UninstallMultipleProtocolInterfaces (\r
                   UsbIf->Handle,\r
-                  &gEfiDevicePathProtocolGuid, UsbIf->DevicePath,\r
-                  &gEfiUsbIoProtocolGuid,      &UsbIf->UsbIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  UsbIf->DevicePath,\r
+                  &gEfiUsbIoProtocolGuid,\r
+                  &UsbIf->UsbIo,\r
                   NULL\r
                   );\r
   if (!EFI_ERROR (Status)) {\r
     if (UsbIf->DevicePath != NULL) {\r
       FreePool (UsbIf->DevicePath);\r
     }\r
+\r
     FreePool (UsbIf);\r
   } else {\r
     UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);\r
   }\r
+\r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Create an interface for the descriptor IfDesc. Each\r
   device's configuration can have several interfaces.\r
@@ -89,14 +91,14 @@ UsbFreeInterface (
 **/\r
 USB_INTERFACE *\r
 UsbCreateInterface (\r
-  IN USB_DEVICE           *Device,\r
-  IN USB_INTERFACE_DESC   *IfDesc\r
+  IN USB_DEVICE          *Device,\r
+  IN USB_INTERFACE_DESC  *IfDesc\r
   )\r
 {\r
-  USB_DEVICE_PATH         UsbNode;\r
-  USB_INTERFACE           *UsbIf;\r
-  USB_INTERFACE           *HubIf;\r
-  EFI_STATUS              Status;\r
+  USB_DEVICE_PATH  UsbNode;\r
+  USB_INTERFACE    *UsbIf;\r
+  USB_INTERFACE    *HubIf;\r
+  EFI_STATUS       Status;\r
 \r
   UsbIf = AllocateZeroPool (sizeof (USB_INTERFACE));\r
 \r
@@ -104,11 +106,11 @@ UsbCreateInterface (
     return NULL;\r
   }\r
 \r
-  UsbIf->Signature  = USB_INTERFACE_SIGNATURE;\r
-  UsbIf->Device     = Device;\r
-  UsbIf->IfDesc     = IfDesc;\r
+  UsbIf->Signature = USB_INTERFACE_SIGNATURE;\r
+  UsbIf->Device    = Device;\r
+  UsbIf->IfDesc    = IfDesc;\r
   ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);\r
-  UsbIf->IfSetting  = IfDesc->Settings[IfDesc->ActiveIndex];\r
+  UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];\r
 \r
   CopyMem (\r
     &(UsbIf->UsbIo),\r
@@ -119,10 +121,10 @@ UsbCreateInterface (
   //\r
   // Install protocols for USBIO and device path\r
   //\r
-  UsbNode.Header.Type       = MESSAGING_DEVICE_PATH;\r
-  UsbNode.Header.SubType    = MSG_USB_DP;\r
-  UsbNode.ParentPortNumber  = Device->ParentPort;\r
-  UsbNode.InterfaceNumber   = UsbIf->IfSetting->Desc.InterfaceNumber;\r
+  UsbNode.Header.Type      = MESSAGING_DEVICE_PATH;\r
+  UsbNode.Header.SubType   = MSG_USB_DP;\r
+  UsbNode.ParentPortNumber = Device->ParentPort;\r
+  UsbNode.InterfaceNumber  = UsbIf->IfSetting->Desc.InterfaceNumber;\r
 \r
   SetDevicePathNodeLength (&UsbNode.Header, sizeof (UsbNode));\r
 \r
@@ -182,7 +184,6 @@ ON_ERROR:
   return NULL;\r
 }\r
 \r
-\r
 /**\r
   Free the resource used by this USB device.\r
 \r
@@ -191,7 +192,7 @@ ON_ERROR:
 **/\r
 VOID\r
 UsbFreeDevice (\r
-  IN USB_DEVICE           *Device\r
+  IN USB_DEVICE  *Device\r
   )\r
 {\r
   if (Device->DevDesc != NULL) {\r
@@ -201,7 +202,6 @@ UsbFreeDevice (
   gBS->FreePool (Device);\r
 }\r
 \r
-\r
 /**\r
   Create a device which is on the parent's ParentPort port.\r
 \r
@@ -213,11 +213,11 @@ UsbFreeDevice (
 **/\r
 USB_DEVICE *\r
 UsbCreateDevice (\r
-  IN USB_INTERFACE        *ParentIf,\r
-  IN UINT8                ParentPort\r
+  IN USB_INTERFACE  *ParentIf,\r
+  IN UINT8          ParentPort\r
   )\r
 {\r
-  USB_DEVICE              *Device;\r
+  USB_DEVICE  *Device;\r
 \r
   ASSERT (ParentIf != NULL);\r
 \r
@@ -227,16 +227,15 @@ UsbCreateDevice (
     return NULL;\r
   }\r
 \r
-  Device->Bus         = ParentIf->Device->Bus;\r
-  Device->MaxPacket0  = 8;\r
-  Device->ParentAddr  = ParentIf->Device->Address;\r
-  Device->ParentIf    = ParentIf;\r
-  Device->ParentPort  = ParentPort;\r
-  Device->Tier        = (UINT8)(ParentIf->Device->Tier + 1);\r
+  Device->Bus        = ParentIf->Device->Bus;\r
+  Device->MaxPacket0 = 8;\r
+  Device->ParentAddr = ParentIf->Device->Address;\r
+  Device->ParentIf   = ParentIf;\r
+  Device->ParentPort = ParentPort;\r
+  Device->Tier       = (UINT8)(ParentIf->Device->Tier + 1);\r
   return Device;\r
 }\r
 \r
-\r
 /**\r
   Connect the USB interface with its driver. EFI USB bus will\r
   create a USB interface for each separate interface descriptor.\r
@@ -249,11 +248,11 @@ UsbCreateDevice (
 **/\r
 EFI_STATUS\r
 UsbConnectDriver (\r
-  IN USB_INTERFACE        *UsbIf\r
+  IN USB_INTERFACE  *UsbIf\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  EFI_TPL                 OldTpl;\r
+  EFI_STATUS  Status;\r
+  EFI_TPL     OldTpl;\r
 \r
   Status = EFI_SUCCESS;\r
 \r
@@ -264,7 +263,6 @@ UsbConnectDriver (
   if (UsbIsHubInterface (UsbIf)) {\r
     DEBUG ((DEBUG_INFO, "UsbConnectDriver: found a hub device\n"));\r
     Status = mUsbHubApi.Init (UsbIf);\r
-\r
   } else {\r
     //\r
     // This function is called in both UsbIoControlTransfer and\r
@@ -278,15 +276,15 @@ UsbConnectDriver (
     // Only recursively wanted usb child device\r
     //\r
     if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) {\r
-      OldTpl            = UsbGetCurrentTpl ();\r
+      OldTpl = UsbGetCurrentTpl ();\r
       DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));\r
 \r
       gBS->RestoreTPL (TPL_CALLBACK);\r
 \r
-      Status            = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);\r
-      UsbIf->IsManaged  = (BOOLEAN)!EFI_ERROR (Status);\r
+      Status           = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);\r
+      UsbIf->IsManaged = (BOOLEAN) !EFI_ERROR (Status);\r
 \r
-      DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));\r
+      DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl ()));\r
       ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);\r
 \r
       gBS->RaiseTPL (OldTpl);\r
@@ -296,7 +294,6 @@ UsbConnectDriver (
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Select an alternate setting for the interface.\r
   Each interface can have several mutually exclusive\r
@@ -312,12 +309,12 @@ UsbConnectDriver (
 **/\r
 EFI_STATUS\r
 UsbSelectSetting (\r
-  IN USB_INTERFACE_DESC   *IfDesc,\r
-  IN UINT8                Alternate\r
+  IN USB_INTERFACE_DESC  *IfDesc,\r
+  IN UINT8               Alternate\r
   )\r
 {\r
-  USB_INTERFACE_SETTING   *Setting;\r
-  UINTN                   Index;\r
+  USB_INTERFACE_SETTING  *Setting;\r
+  UINTN                  Index;\r
 \r
   //\r
   // Locate the active alternate setting\r
@@ -340,8 +337,12 @@ UsbSelectSetting (
   IfDesc->ActiveIndex = Index;\r
 \r
   ASSERT (Setting != NULL);\r
-  DEBUG ((DEBUG_INFO, "UsbSelectSetting: setting %d selected for interface %d\n",\r
-              Alternate, Setting->Desc.InterfaceNumber));\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "UsbSelectSetting: setting %d selected for interface %d\n",\r
+    Alternate,\r
+    Setting->Desc.InterfaceNumber\r
+    ));\r
 \r
   //\r
   // Reset the endpoint toggle to zero\r
@@ -353,7 +354,6 @@ UsbSelectSetting (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Select a new configuration for the device. Each\r
   device may support several configurations.\r
@@ -368,22 +368,22 @@ UsbSelectSetting (
 **/\r
 EFI_STATUS\r
 UsbSelectConfig (\r
-  IN USB_DEVICE           *Device,\r
-  IN UINT8                ConfigValue\r
+  IN USB_DEVICE  *Device,\r
+  IN UINT8       ConfigValue\r
   )\r
 {\r
-  USB_DEVICE_DESC         *DevDesc;\r
-  USB_CONFIG_DESC         *ConfigDesc;\r
-  USB_INTERFACE_DESC      *IfDesc;\r
-  USB_INTERFACE           *UsbIf;\r
-  EFI_STATUS              Status;\r
-  UINT8                   Index;\r
+  USB_DEVICE_DESC     *DevDesc;\r
+  USB_CONFIG_DESC     *ConfigDesc;\r
+  USB_INTERFACE_DESC  *IfDesc;\r
+  USB_INTERFACE       *UsbIf;\r
+  EFI_STATUS          Status;\r
+  UINT8               Index;\r
 \r
   //\r
   // Locate the active config, then set the device's pointer\r
   //\r
-  DevDesc     = Device->DevDesc;\r
-  ConfigDesc  = NULL;\r
+  DevDesc    = Device->DevDesc;\r
+  ConfigDesc = NULL;\r
 \r
   for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {\r
     ConfigDesc = DevDesc->Configs[Index];\r
@@ -399,8 +399,12 @@ UsbSelectConfig (
 \r
   Device->ActiveConfig = ConfigDesc;\r
 \r
-  DEBUG ((DEBUG_INFO, "UsbSelectConfig: config %d selected for device %d\n",\r
-              ConfigValue, Device->Address));\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "UsbSelectConfig: config %d selected for device %d\n",\r
+    ConfigValue,\r
+    Device->Address\r
+    ));\r
 \r
   //\r
   // Create interfaces for each USB interface descriptor.\r
@@ -447,7 +451,6 @@ UsbSelectConfig (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Disconnect the USB interface with its driver.\r
 \r
@@ -456,11 +459,11 @@ UsbSelectConfig (
 **/\r
 EFI_STATUS\r
 UsbDisconnectDriver (\r
-  IN USB_INTERFACE        *UsbIf\r
+  IN USB_INTERFACE  *UsbIf\r
   )\r
 {\r
-  EFI_TPL                 OldTpl;\r
-  EFI_STATUS              Status;\r
+  EFI_TPL     OldTpl;\r
+  EFI_STATUS  Status;\r
 \r
   //\r
   // Release the hub if it's a hub controller, otherwise\r
@@ -469,7 +472,6 @@ UsbDisconnectDriver (
   Status = EFI_SUCCESS;\r
   if (UsbIf->IsHub) {\r
     Status = UsbIf->HubApi->Release (UsbIf);\r
-\r
   } else if (UsbIf->IsManaged) {\r
     //\r
     // This function is called in both UsbIoControlTransfer and\r
@@ -478,7 +480,7 @@ UsbDisconnectDriver (
     // twisted TPL used. It should be no problem for us to connect\r
     // or disconnect at CALLBACK.\r
     //\r
-    OldTpl           = UsbGetCurrentTpl ();\r
+    OldTpl = UsbGetCurrentTpl ();\r
     DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));\r
 \r
     gBS->RestoreTPL (TPL_CALLBACK);\r
@@ -488,7 +490,7 @@ UsbDisconnectDriver (
       UsbIf->IsManaged = FALSE;\r
     }\r
 \r
-    DEBUG (( DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status));\r
+    DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl (), Status));\r
     ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);\r
 \r
     gBS->RaiseTPL (OldTpl);\r
@@ -497,7 +499,6 @@ UsbDisconnectDriver (
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Remove the current device configuration.\r
 \r
@@ -506,13 +507,13 @@ UsbDisconnectDriver (
 **/\r
 EFI_STATUS\r
 UsbRemoveConfig (\r
-  IN USB_DEVICE           *Device\r
+  IN USB_DEVICE  *Device\r
   )\r
 {\r
-  USB_INTERFACE           *UsbIf;\r
-  UINTN                   Index;\r
-  EFI_STATUS              Status;\r
-  EFI_STATUS              ReturnStatus;\r
+  USB_INTERFACE  *UsbIf;\r
+  UINTN          Index;\r
+  EFI_STATUS     Status;\r
+  EFI_STATUS     ReturnStatus;\r
 \r
   //\r
   // Remove each interface of the device\r
@@ -541,11 +542,10 @@ UsbRemoveConfig (
     }\r
   }\r
 \r
-  Device->ActiveConfig    = NULL;\r
+  Device->ActiveConfig = NULL;\r
   return ReturnStatus;\r
 }\r
 \r
-\r
 /**\r
   Remove the device and all its children from the bus.\r
 \r
@@ -556,14 +556,14 @@ UsbRemoveConfig (
 **/\r
 EFI_STATUS\r
 UsbRemoveDevice (\r
-  IN USB_DEVICE           *Device\r
+  IN USB_DEVICE  *Device\r
   )\r
 {\r
-  USB_BUS                 *Bus;\r
-  USB_DEVICE              *Child;\r
-  EFI_STATUS              Status;\r
-  EFI_STATUS              ReturnStatus;\r
-  UINTN                   Index;\r
+  USB_BUS     *Bus;\r
+  USB_DEVICE  *Child;\r
+  EFI_STATUS  Status;\r
+  EFI_STATUS  ReturnStatus;\r
+  UINTN       Index;\r
 \r
   Bus = Device->Bus;\r
 \r
@@ -585,7 +585,7 @@ UsbRemoveDevice (
       Bus->Devices[Index] = NULL;\r
     } else {\r
       Bus->Devices[Index]->DisconnectFail = TRUE;\r
-      ReturnStatus = Status;\r
+      ReturnStatus                        = Status;\r
       DEBUG ((DEBUG_INFO, "UsbRemoveDevice: failed to remove child %p at parent %p\n", Child, Device));\r
     }\r
   }\r
@@ -597,7 +597,7 @@ UsbRemoveDevice (
   Status = UsbRemoveConfig (Device);\r
 \r
   if (!EFI_ERROR (Status)) {\r
-    DEBUG (( DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));\r
+    DEBUG ((DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));\r
 \r
     ASSERT (Device->Address < Bus->MaxDevices);\r
     Bus->Devices[Device->Address] = NULL;\r
@@ -605,10 +605,10 @@ UsbRemoveDevice (
   } else {\r
     Bus->Devices[Device->Address]->DisconnectFail = TRUE;\r
   }\r
+\r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Find the child device on the hub's port.\r
 \r
@@ -620,13 +620,13 @@ UsbRemoveDevice (
 **/\r
 USB_DEVICE *\r
 UsbFindChild (\r
-  IN USB_INTERFACE        *HubIf,\r
-  IN UINT8                Port\r
+  IN USB_INTERFACE  *HubIf,\r
+  IN UINT8          Port\r
   )\r
 {\r
-  USB_DEVICE              *Device;\r
-  USB_BUS                 *Bus;\r
-  UINTN                   Index;\r
+  USB_DEVICE  *Device;\r
+  USB_BUS     *Bus;\r
+  UINTN       Index;\r
 \r
   Bus = HubIf->Device->Bus;\r
 \r
@@ -637,8 +637,8 @@ UsbFindChild (
     Device = Bus->Devices[Index];\r
 \r
     if ((Device != NULL) && (Device->ParentAddr == HubIf->Device->Address) &&\r
-        (Device->ParentPort == Port)) {\r
-\r
+        (Device->ParentPort == Port))\r
+    {\r
       return Device;\r
     }\r
   }\r
@@ -646,7 +646,6 @@ UsbFindChild (
   return NULL;\r
 }\r
 \r
-\r
 /**\r
   Enumerate and configure the new device on the port of this HUB interface.\r
 \r
@@ -661,19 +660,19 @@ UsbFindChild (
 **/\r
 EFI_STATUS\r
 UsbEnumerateNewDev (\r
-  IN USB_INTERFACE        *HubIf,\r
-  IN UINT8                Port,\r
-  IN BOOLEAN              ResetIsNeeded\r
+  IN USB_INTERFACE  *HubIf,\r
+  IN UINT8          Port,\r
+  IN BOOLEAN        ResetIsNeeded\r
   )\r
 {\r
-  USB_BUS                 *Bus;\r
-  USB_HUB_API             *HubApi;\r
-  USB_DEVICE              *Child;\r
-  USB_DEVICE              *Parent;\r
-  EFI_USB_PORT_STATUS     PortState;\r
-  UINTN                   Address;\r
-  UINT8                   Config;\r
-  EFI_STATUS              Status;\r
+  USB_BUS              *Bus;\r
+  USB_HUB_API          *HubApi;\r
+  USB_DEVICE           *Child;\r
+  USB_DEVICE           *Parent;\r
+  EFI_USB_PORT_STATUS  PortState;\r
+  UINTN                Address;\r
+  UINT8                Config;\r
+  EFI_STATUS           Status;\r
 \r
   Parent  = HubIf->Device;\r
   Bus     = Parent->Bus;\r
@@ -695,9 +694,10 @@ UsbEnumerateNewDev (
 \r
       return Status;\r
     }\r
-    DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));\r
+\r
+    DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));\r
   } else {\r
-    DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));\r
+    DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));\r
   }\r
 \r
   Child = UsbCreateDevice (HubIf, Port);\r
@@ -721,7 +721,7 @@ UsbEnumerateNewDev (
     DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port));\r
     Status = EFI_NOT_FOUND;\r
     goto ON_ERROR;\r
-  } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){\r
+  } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {\r
     Child->Speed      = EFI_USB_SPEED_SUPER;\r
     Child->MaxPacket0 = 512;\r
   } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {\r
@@ -735,10 +735,11 @@ UsbEnumerateNewDev (
     Child->MaxPacket0 = 8;\r
   }\r
 \r
-  DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));\r
+  DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));\r
 \r
   if (((Child->Speed == EFI_USB_SPEED_LOW) || (Child->Speed == EFI_USB_SPEED_FULL)) &&\r
-      (Parent->Speed == EFI_USB_SPEED_HIGH)) {\r
+      (Parent->Speed == EFI_USB_SPEED_HIGH))\r
+  {\r
     //\r
     // If the child is a low or full speed device, it is necessary to\r
     // set the transaction translator. Port TT is 1-based.\r
@@ -746,14 +747,18 @@ UsbEnumerateNewDev (
     //  1. if parent is of high speed, then parent is our translator\r
     //  2. otherwise use parent's translator.\r
     //\r
-    Child->Translator.TranslatorHubAddress  = Parent->Address;\r
-    Child->Translator.TranslatorPortNumber  = (UINT8) (Port + 1);\r
+    Child->Translator.TranslatorHubAddress = Parent->Address;\r
+    Child->Translator.TranslatorPortNumber = (UINT8)(Port + 1);\r
   } else {\r
     Child->Translator = Parent->Translator;\r
   }\r
-  DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device uses translator (%d, %d)\n",\r
-           Child->Translator.TranslatorHubAddress,\r
-           Child->Translator.TranslatorPortNumber));\r
+\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "UsbEnumerateNewDev: device uses translator (%d, %d)\n",\r
+    Child->Translator.TranslatorHubAddress,\r
+    Child->Translator.TranslatorPortNumber\r
+    ));\r
 \r
   //\r
   // After port is reset, hub establishes a signal path between\r
@@ -805,7 +810,7 @@ UsbEnumerateNewDev (
     goto ON_ERROR;\r
   }\r
 \r
-  DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));\r
+  DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));\r
 \r
   //\r
   // Host learns about the device's abilities by requesting device's\r
@@ -830,7 +835,7 @@ UsbEnumerateNewDev (
     goto ON_ERROR;\r
   }\r
 \r
-  DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));\r
+  DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));\r
 \r
   //\r
   // Host assigns and loads a device driver.\r
@@ -870,7 +875,6 @@ ON_ERROR:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Process the events on the port.\r
 \r
@@ -884,17 +888,17 @@ ON_ERROR:
 **/\r
 EFI_STATUS\r
 UsbEnumeratePort (\r
-  IN USB_INTERFACE        *HubIf,\r
-  IN UINT8                Port\r
+  IN USB_INTERFACE  *HubIf,\r
+  IN UINT8          Port\r
   )\r
 {\r
-  USB_HUB_API             *HubApi;\r
-  USB_DEVICE              *Child;\r
-  EFI_USB_PORT_STATUS     PortState;\r
-  EFI_STATUS              Status;\r
+  USB_HUB_API          *HubApi;\r
+  USB_DEVICE           *Child;\r
+  EFI_USB_PORT_STATUS  PortState;\r
+  EFI_STATUS           Status;\r
 \r
-  Child   = NULL;\r
-  HubApi  = HubIf->HubApi;\r
+  Child  = NULL;\r
+  HubApi = HubIf->HubApi;\r
 \r
   //\r
   // Host learns of the new device by polling the hub for port changes.\r
@@ -914,8 +918,14 @@ UsbEnumeratePort (
     return EFI_SUCCESS;\r
   }\r
 \r
-  DEBUG (( DEBUG_INFO, "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",\r
-              Port, PortState.PortStatus, PortState.PortChangeStatus, HubIf));\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",\r
+    Port,\r
+    PortState.PortStatus,\r
+    PortState.PortChangeStatus,\r
+    HubIf\r
+    ));\r
 \r
   //\r
   // This driver only process two kinds of events now: over current and\r
@@ -924,7 +934,6 @@ UsbEnumeratePort (
   //\r
 \r
   if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_OVERCURRENT)) {\r
-\r
     if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_OVERCURRENT)) {\r
       //\r
       // Case1:\r
@@ -932,17 +941,17 @@ UsbEnumeratePort (
       //   which probably is caused by short circuit. It has to wait system hardware\r
       //   to perform recovery.\r
       //\r
-      DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));\r
+      DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));\r
       return EFI_DEVICE_ERROR;\r
-\r
     }\r
+\r
     //\r
     // Case2:\r
     //   Only OverCurrentChange set, means system has been recoveried from\r
     //   over current. As a result, all ports are nearly power-off, so\r
     //   it's necessary to detach and enumerate all ports again.\r
     //\r
-    DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));\r
+    DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));\r
   }\r
 \r
   if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) {\r
@@ -952,7 +961,7 @@ UsbEnumeratePort (
     //   on 2.0 roothub does. When over-current has influence on 1.1 device, the port\r
     //   would be disabled, so it's also necessary to detach and enumerate again.\r
     //\r
-    DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));\r
+    DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));\r
   }\r
 \r
   if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) {\r
@@ -969,7 +978,7 @@ UsbEnumeratePort (
   Child = UsbFindChild (HubIf, Port);\r
 \r
   if (Child != NULL) {\r
-    DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));\r
+    DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));\r
     UsbRemoveDevice (Child);\r
   }\r
 \r
@@ -977,22 +986,20 @@ UsbEnumeratePort (
     //\r
     // Now, new device connected, enumerate and configure the device\r
     //\r
-    DEBUG (( DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));\r
+    DEBUG ((DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));\r
     if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {\r
       Status = UsbEnumerateNewDev (HubIf, Port, FALSE);\r
     } else {\r
       Status = UsbEnumerateNewDev (HubIf, Port, TRUE);\r
     }\r
-\r
   } else {\r
-    DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));\r
+    DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));\r
   }\r
 \r
   HubApi->ClearPortChange (HubIf, Port);\r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Enumerate all the changed hub ports.\r
 \r
@@ -1003,37 +1010,37 @@ UsbEnumeratePort (
 VOID\r
 EFIAPI\r
 UsbHubEnumeration (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
   )\r
 {\r
-  USB_INTERFACE           *HubIf;\r
-  UINT8                   Byte;\r
-  UINT8                   Bit;\r
-  UINT8                   Index;\r
-  USB_DEVICE              *Child;\r
+  USB_INTERFACE  *HubIf;\r
+  UINT8          Byte;\r
+  UINT8          Bit;\r
+  UINT8          Index;\r
+  USB_DEVICE     *Child;\r
 \r
   ASSERT (Context != NULL);\r
 \r
-  HubIf = (USB_INTERFACE *) Context;\r
+  HubIf = (USB_INTERFACE *)Context;\r
 \r
   for (Index = 0; Index < HubIf->NumOfPort; Index++) {\r
     Child = UsbFindChild (HubIf, Index);\r
     if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {\r
-      DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));\r
+      DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));\r
       UsbRemoveDevice (Child);\r
     }\r
   }\r
 \r
   if (HubIf->ChangeMap == NULL) {\r
-    return ;\r
+    return;\r
   }\r
 \r
   //\r
   // HUB starts its port index with 1.\r
   //\r
-  Byte  = 0;\r
-  Bit   = 1;\r
+  Byte = 0;\r
+  Bit  = 1;\r
 \r
   for (Index = 0; Index < HubIf->NumOfPort; Index++) {\r
     if (USB_BIT_IS_SET (HubIf->ChangeMap[Byte], USB_BIT (Bit))) {\r
@@ -1047,10 +1054,9 @@ UsbHubEnumeration (
 \r
   gBS->FreePool (HubIf->ChangeMap);\r
   HubIf->ChangeMap = NULL;\r
-  return ;\r
+  return;\r
 }\r
 \r
-\r
 /**\r
   Enumerate all the changed hub ports.\r
 \r
@@ -1061,20 +1067,20 @@ UsbHubEnumeration (
 VOID\r
 EFIAPI\r
 UsbRootHubEnumeration (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
   )\r
 {\r
-  USB_INTERFACE           *RootHub;\r
-  UINT8                   Index;\r
-  USB_DEVICE              *Child;\r
+  USB_INTERFACE  *RootHub;\r
+  UINT8          Index;\r
+  USB_DEVICE     *Child;\r
 \r
-  RootHub = (USB_INTERFACE *) Context;\r
+  RootHub = (USB_INTERFACE *)Context;\r
 \r
   for (Index = 0; Index < RootHub->NumOfPort; Index++) {\r
     Child = UsbFindChild (RootHub, Index);\r
     if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {\r
-      DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));\r
+      DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));\r
       UsbRemoveDevice (Child);\r
     }\r
 \r