]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
check the usage of %d,%x,%ld,%lx and so on in debug print statement.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbUtility.c
index 37e6c05a2fb406b032eb2123b08cc46277035998..eb41de5ecfe53ac5f995de5879881243033f2781 100644 (file)
@@ -1,5 +1,7 @@
 /** @file\r
 \r
+    Wrapper function for usb host controller interface.\r
+\r
 Copyright (c) 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -9,17 +11,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-  Module Name:\r
-\r
-    UsbUtility.c\r
-\r
-  Abstract:\r
-\r
-    Wrapper function for usb host controller interface\r
-\r
-  Revision History\r
-\r
-\r
 **/\r
 \r
 \r
@@ -30,13 +21,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // Use a shor form Usb class Device Path, which could match any usb device, in WantedUsbIoDPList to indicate all Usb devices\r
 // are wanted Usb devices\r
 //\r
-STATIC USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {\r
+USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {\r
   {\r
     {\r
       MESSAGING_DEVICE_PATH,\r
       MSG_USB_CLASS_DP,\r
-      (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),\r
-      (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)\r
+      {\r
+        (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),\r
+        (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)\r
+      }\r
     },\r
     0xffff, // VendorId\r
     0xffff, // ProductId\r
@@ -48,21 +41,23 @@ STATIC USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
   {\r
     END_DEVICE_PATH_TYPE,\r
     END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    END_DEVICE_PATH_LENGTH,\r
-    0\r
+    {\r
+      END_DEVICE_PATH_LENGTH,\r
+      0\r
+    }\r
   }\r
 };\r
 \r
 \r
 /**\r
-  Get the capability of the host controller\r
+  Get the capability of the host controller.\r
 \r
-  @param  UsbBus           The usb driver\r
-  @param  MaxSpeed         The maximum speed this host controller supports\r
-  @param  NumOfPort        The number of the root hub port\r
-  @param  Is64BitCapable   Whether this controller support 64 bit addressing\r
+  @param  UsbBus           The usb driver.\r
+  @param  MaxSpeed         The maximum speed this host controller supports.\r
+  @param  NumOfPort        The number of the root hub port.\r
+  @param  Is64BitCapable   Whether this controller support 64 bit addressing.\r
 \r
-  @retval EFI_SUCCESS      The host controller capability is returned\r
+  @retval EFI_SUCCESS      The host controller capability is returned.\r
   @retval Others           Failed to retrieve the host controller capability.\r
 \r
 **/\r
@@ -96,13 +91,16 @@ UsbHcGetCapability (
 \r
 \r
 /**\r
-  Reset the host controller\r
+  Reset the host controller.\r
 \r
-  @param  UsbBus           The usb bus driver\r
-  @param  Attributes       The reset type, only global reset is used by this driver\r
-\r
-  @return GC_TODO: add return values\r
+  @param  UsbBus                The usb bus driver.\r
+  @param  Attributes            The reset type, only global reset is used by this driver.\r
 \r
+  @retval EFI_SUCCESS           The reset operation succeeded.\r
+  @retval EFI_INVALID_PARAMETER Attributes is not valid.\r
+  @retval EFI_UNSUPPOURTED      The type of reset specified by Attributes is\r
+                                not currently supported by the host controller.\r
+  @retval EFI_DEVICE_ERROR      Host controller isn't halted to reset.\r
 **/\r
 EFI_STATUS\r
 UsbHcReset (\r
@@ -123,13 +121,13 @@ UsbHcReset (
 \r
 \r
 /**\r
-  Get the current operation state of the host controller\r
+  Get the current operation state of the host controller.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  State            The host controller operation state\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  State            The host controller operation state.\r
 \r
-  @retval EFI_SUCCESS      The operation state is returned in State\r
-  @retval Others           Failed to get the host controller state\r
+  @retval EFI_SUCCESS      The operation state is returned in State.\r
+  @retval Others           Failed to get the host controller state.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -151,13 +149,13 @@ UsbHcGetState (
 \r
 \r
 /**\r
-  Set the host controller operation state\r
+  Set the host controller operation state.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  State            The state to set\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  State            The state to set.\r
 \r
-  @retval EFI_SUCCESS      The host controller is now working at State\r
-  @retval Others           Failed to set operation state\r
+  @retval EFI_SUCCESS      The host controller is now working at State.\r
+  @retval Others           Failed to set operation state.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -179,14 +177,14 @@ UsbHcSetState (
 \r
 \r
 /**\r
-  Get the root hub port state\r
+  Get the root hub port state.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  PortIndex        The index of port\r
-  @param  PortStatus       The variable to save port state\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The index of port.\r
+  @param  PortStatus       The variable to save port state.\r
 \r
-  @retval EFI_SUCCESS      The root port state is returned in\r
-  @retval Others           Failed to get the root hub port state\r
+  @retval EFI_SUCCESS      The root port state is returned in.\r
+  @retval Others           Failed to get the root hub port state.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -209,14 +207,14 @@ UsbHcGetRootHubPortStatus (
 \r
 \r
 /**\r
-  Set the root hub port feature\r
+  Set the root hub port feature.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  PortIndex        The port index\r
-  @param  Feature          The port feature to set\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The port index.\r
+  @param  Feature          The port feature to set.\r
 \r
-  @retval EFI_SUCCESS      The port feature is set\r
-  @retval Others           Failed to set port feature\r
+  @retval EFI_SUCCESS      The port feature is set.\r
+  @retval Others           Failed to set port feature.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -240,14 +238,14 @@ UsbHcSetRootHubPortFeature (
 \r
 \r
 /**\r
-  Clear the root hub port feature\r
+  Clear the root hub port feature.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  PortIndex        The port index\r
-  @param  Feature          The port feature to clear\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The port index.\r
+  @param  Feature          The port feature to clear.\r
 \r
-  @retval EFI_SUCCESS      The port feature is clear\r
-  @retval Others           Failed to clear port feature\r
+  @retval EFI_SUCCESS      The port feature is clear.\r
+  @retval Others           Failed to clear port feature.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -270,22 +268,22 @@ UsbHcClearRootHubPortFeature (
 \r
 \r
 /**\r
-  Execute a control transfer to the device\r
-\r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The device address\r
-  @param  DevSpeed         The device speed\r
-  @param  MaxPacket        Maximum packet size of endpoint 0\r
-  @param  Request          The control transfer request\r
-  @param  Direction        The direction of data stage\r
-  @param  Data             The buffer holding data\r
-  @param  DataLength       The length of the data\r
-  @param  TimeOut          Timeout (in ms) to wait until timeout\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  UsbResult        The result of transfer\r
-\r
-  @retval EFI_SUCCESS      The control transfer finished without error\r
-  @retval Others           The control transfer failed, reason returned in UsbReslt\r
+  Execute a control transfer to the device.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The device address.\r
+  @param  DevSpeed         The device speed.\r
+  @param  MaxPacket        Maximum packet size of endpoint 0.\r
+  @param  Request          The control transfer request.\r
+  @param  Direction        The direction of data stage.\r
+  @param  Data             The buffer holding data.\r
+  @param  DataLength       The length of the data.\r
+  @param  TimeOut          Timeout (in ms) to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of transfer.\r
+\r
+  @retval EFI_SUCCESS      The control transfer finished without error.\r
+  @retval Others           The control transfer failed, reason returned in UsbReslt.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -342,25 +340,25 @@ UsbHcControlTransfer (
 \r
 \r
 /**\r
-  Execute a bulk transfer to the device's endpoint\r
+  Execute a bulk transfer to the device's endpoint.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The target device address\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
   @param  EpAddr           The target endpoint address, with direction encoded in\r
-                           bit 7\r
-  @param  DevSpeed         The device's speed\r
-  @param  MaxPacket        The endpoint's max packet size\r
-  @param  BufferNum        The number of data buffer\r
-  @param  Data             Array of pointers to data buffer\r
-  @param  DataLength       The length of data buffer\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
   @param  DataToggle       On input, the initial data toggle to use, also  return\r
                            the next toggle on output.\r
-  @param  TimeOut          The time to wait until timeout\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  UsbResult        The result of USB execution\r
+  @param  TimeOut          The time to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
 \r
-  @retval EFI_SUCCESS      The bulk transfer is finished without error\r
-  @retval Others           Failed to execute bulk transfer, result in UsbResult\r
+  @retval EFI_SUCCESS      The bulk transfer is finished without error.\r
+  @retval Others           Failed to execute bulk transfer, result in UsbResult.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -415,25 +413,25 @@ UsbHcBulkTransfer (
 \r
 \r
 /**\r
-  Queue or cancel an asynchronous interrupt transfer\r
+  Queue or cancel an asynchronous interrupt transfer.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The target device address\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
   @param  EpAddr           The target endpoint address, with direction encoded in\r
-                           bit 7\r
-  @param  DevSpeed         The device's speed\r
-  @param  MaxPacket        The endpoint's max packet size\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
   @param  IsNewTransfer    Whether this is a new request. If not, cancel the old\r
-                           request\r
-  @param  DataToggle       Data toggle to use on input, next toggle on output\r
-  @param  PollingInterval  The interval to poll the interrupt transfer (in ms)\r
-  @param  DataLength       The length of periodical data receive\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  Callback         Function to call when data is received\r
-  @param  Context          The context to the callback\r
+                           request.\r
+  @param  DataToggle       Data toggle to use on input, next toggle on output.\r
+  @param  PollingInterval  The interval to poll the interrupt transfer (in ms).\r
+  @param  DataLength       The length of periodical data receive.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  Callback         Function to call when data is received.\r
+  @param  Context          The context to the callback.\r
 \r
-  @retval EFI_SUCCESS      The asynchronous transfer is queued\r
-  @retval Others           Failed to queue the transfer\r
+  @retval EFI_SUCCESS      The asynchronous transfer is queued.\r
+  @retval Others           Failed to queue the transfer.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -493,24 +491,24 @@ UsbHcAsyncInterruptTransfer (
 \r
 \r
 /**\r
-  Execute a synchronous interrupt transfer to the target endpoint\r
+  Execute a synchronous interrupt transfer to the target endpoint.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The target device address\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
   @param  EpAddr           The target endpoint address, with direction encoded in\r
-                           bit 7\r
-  @param  DevSpeed         The device's speed\r
-  @param  MaxPacket        The endpoint's max packet size\r
-  @param  Data             Pointer to data buffer\r
-  @param  DataLength       The length of data buffer\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  Data             Pointer to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
   @param  DataToggle       On input, the initial data toggle to use, also  return\r
                            the next toggle on output.\r
-  @param  TimeOut          The time to wait until timeout\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  UsbResult        The result of USB execution\r
+  @param  TimeOut          The time to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
 \r
-  @retval EFI_SUCCESS      The synchronous interrupt transfer is OK\r
-  @retval Others           Failed to execute the synchronous interrupt transfer\r
+  @retval EFI_SUCCESS      The synchronous interrupt transfer is OK.\r
+  @retval Others           Failed to execute the synchronous interrupt transfer.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -566,21 +564,21 @@ UsbHcSyncInterruptTransfer (
 \r
 \r
 /**\r
-  Execute a synchronous Isochronous USB transfer\r
+  Execute a synchronous Isochronous USB transfer.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The target device address\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
   @param  EpAddr           The target endpoint address, with direction encoded in\r
-                           bit 7\r
-  @param  DevSpeed         The device's speed\r
-  @param  MaxPacket        The endpoint's max packet size\r
-  @param  BufferNum        The number of data buffer\r
-  @param  Data             Array of pointers to data buffer\r
-  @param  DataLength       The length of data buffer\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  UsbResult        The result of USB execution\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
 \r
-  @retval EFI_UNSUPPORTED  The isochronous transfer isn't supported now\r
+  @retval EFI_UNSUPPORTED  The isochronous transfer isn't supported now.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -602,22 +600,22 @@ UsbHcIsochronousTransfer (
 \r
 \r
 /**\r
-  Queue an asynchronous isochronous transfer\r
+  Queue an asynchronous isochronous transfer.\r
 \r
-  @param  UsbBus           The USB bus driver\r
-  @param  DevAddr          The target device address\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
   @param  EpAddr           The target endpoint address, with direction encoded in\r
-                           bit 7\r
-  @param  DevSpeed         The device's speed\r
-  @param  MaxPacket        The endpoint's max packet size\r
-  @param  BufferNum        The number of data buffer\r
-  @param  Data             Array of pointers to data buffer\r
-  @param  DataLength       The length of data buffer\r
-  @param  Translator       The transaction translator for low/full speed device\r
-  @param  Callback         The function to call when data is transferred\r
-  @param  Context          The context to the callback function\r
-\r
-  @retval EFI_UNSUPPORTED  The asynchronous isochronous transfer isn't supported\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  Callback         The function to call when data is transferred.\r
+  @param  Context          The context to the callback function.\r
+\r
+  @retval EFI_UNSUPPORTED  The asynchronous isochronous transfer isn't supported.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -640,12 +638,12 @@ UsbHcAsyncIsochronousTransfer (
 \r
 \r
 /**\r
-  Open the USB host controller protocol BY_CHILD\r
+  Open the USB host controller protocol BY_CHILD.\r
 \r
-  @param  Bus              The USB bus driver\r
-  @param  Child            The child handle\r
+  @param  Bus              The USB bus driver.\r
+  @param  Child            The child handle.\r
 \r
-  @return The open protocol return\r
+  @return The open protocol return.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -684,12 +682,12 @@ UsbOpenHostProtoByChild (
 \r
 \r
 /**\r
-  Close the USB host controller protocol BY_CHILD\r
+  Close the USB host controller protocol BY_CHILD.\r
 \r
-  @param  Bus              The USB bus driver\r
-  @param  Child            The child handle\r
+  @param  Bus              The USB bus driver.\r
+  @param  Child            The child handle.\r
 \r
-  @return None\r
+  @return None.\r
 \r
 **/\r
 VOID\r
@@ -717,13 +715,12 @@ UsbCloseHostProtoByChild (
 }\r
 \r
 \r
-\r
 /**\r
   return the current TPL, copied from the EDKII glue lib.\r
 \r
-  VOID\r
+  @param  VOID.\r
 \r
-  @return Current TPL\r
+  @return Current TPL.\r
 \r
 **/\r
 EFI_TPL\r
@@ -740,11 +737,11 @@ UsbGetCurrentTpl (
 }\r
 \r
 /**\r
-  Create a new device path which only contain the first Usb part of the DevicePath\r
+  Create a new device path which only contain the first Usb part of the DevicePath.\r
 \r
-  @param DevicePath  A full device path which contain the usb nodes\r
+  @param DevicePath  A full device path which contain the usb nodes.\r
 \r
-  @return            A new device path which only contain the Usb part of the DevicePath\r
+  @return            A new device path which only contain the Usb part of the DevicePath.\r
 \r
 **/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
@@ -762,7 +759,7 @@ GetUsbDPFromFullDP (
   // Get the Usb part first Begin node in full device path\r
   //\r
   UsbDevicePathBeginPtr = DevicePath;\r
-  while ( (!EfiIsDevicePathEnd (UsbDevicePathBeginPtr))&&\r
+  while ( (!IsDevicePathEnd (UsbDevicePathBeginPtr))&&\r
          ((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||\r
          (UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&\r
           UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP\r
@@ -776,7 +773,7 @@ GetUsbDPFromFullDP (
   // Get the Usb part first End node in full device path\r
   //\r
   UsbDevicePathEndPtr = UsbDevicePathBeginPtr;\r
-  while ((!EfiIsDevicePathEnd (UsbDevicePathEndPtr))&&\r
+  while ((!IsDevicePathEnd (UsbDevicePathEndPtr))&&\r
          (UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&\r
          (UsbDevicePathEndPtr->SubType == MSG_USB_DP ||\r
           UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP\r
@@ -812,11 +809,11 @@ GetUsbDPFromFullDP (
 /**\r
   Check whether a usb device path is in a DEVICE_PATH_LIST_ITEM list.\r
 \r
-  @param UsbDP       a usb device path of DEVICE_PATH_LIST_ITEM\r
-  @parem UsbIoDPList a DEVICE_PATH_LIST_ITEM list\r
+  @param UsbDP       a usb device path of DEVICE_PATH_LIST_ITEM.\r
+  @param UsbIoDPList a DEVICE_PATH_LIST_ITEM list.\r
 \r
-  @retval TRUE       there is a DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP\r
-  @retval FALSE      there is no DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP\r
+  @retval TRUE       there is a DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP.\r
+  @retval FALSE      there is no DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP.\r
 \r
 **/\r
 BOOLEAN\r
@@ -863,11 +860,11 @@ SearchUsbDPInList (
 /**\r
   Add a usb device path into the DEVICE_PATH_LIST_ITEM list.\r
 \r
-  @param UsbDP        a usb device path of DEVICE_PATH_LIST_ITEM\r
-  @param UsbIoDPList  a DEVICE_PATH_LIST_ITEM list\r
+  @param UsbDP                   a usb device path of DEVICE_PATH_LIST_ITEM.\r
+  @param UsbIoDPList             a DEVICE_PATH_LIST_ITEM list.\r
 \r
-  @retval EFI_INVALID_PARAMETER\r
-  @retval EFI_SUCCESS\r
+  @retval EFI_INVALID_PARAMETER  If parameters are invalid, return this value.\r
+  @retval EFI_SUCCESS            If Add operation is successful, return this value.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -905,13 +902,13 @@ AddUsbDPToList (
 \r
 /**\r
   Check whether usb device, whose interface is UsbIf, matches the usb class which indicated by\r
-  UsbClassDevicePathPtr whose is a short form usb class device path\r
+  UsbClassDevicePathPtr whose is a short form usb class device path.\r
 \r
-  @param UsbClassDevicePathPtr    a short form usb class device path\r
-  @param UsbIf                    a usb device interface\r
+  @param UsbClassDevicePathPtr    a short form usb class device path.\r
+  @param UsbIf                    a usb device interface.\r
 \r
-  @retval TRUE                    the usb device match the usb class\r
-  @retval FALSE                   the usb device does not match the usb class\r
+  @retval TRUE                    the usb device match the usb class.\r
+  @retval FALSE                   the usb device does not match the usb class.\r
 \r
 **/\r
 BOOLEAN\r
@@ -956,25 +953,25 @@ MatchUsbClass (
     //\r
     // If class or subclass or protocol is 0, the counterparts in interface should be checked.\r
     //\r
-    if (DevDesc->DeviceClass == 0 &&\r
-        DevDesc->DeviceSubClass == 0 &&\r
+    if (DevDesc->DeviceClass == 0 ||\r
+        DevDesc->DeviceSubClass == 0 ||\r
         DevDesc->DeviceProtocol == 0) {\r
 \r
       if ((UsbClassDevicePathPtr->DeviceClass == ActIfDesc->InterfaceClass ||\r
                                           UsbClassDevicePathPtr->DeviceClass == 0xff) &&\r
           (UsbClassDevicePathPtr->DeviceSubClass == ActIfDesc->InterfaceSubClass ||\r
                                        UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&\r
-          (UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol) ||\r
-                                       UsbClassDevicePathPtr->DeviceProtocol == 0xff) {\r
+          (UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol ||\r
+                                       UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {\r
         return TRUE;\r
       }\r
 \r
-    } else if ((UsbClassDevicePathPtr->DeviceClass != DevDesc->DeviceClass ||\r
+    } else if ((UsbClassDevicePathPtr->DeviceClass == DevDesc->DeviceClass ||\r
                                          UsbClassDevicePathPtr->DeviceClass == 0xff) &&\r
                (UsbClassDevicePathPtr->DeviceSubClass == DevDesc->DeviceSubClass ||\r
                                       UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&\r
-               (UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol) ||\r
-                                      UsbClassDevicePathPtr->DeviceProtocol == 0xff) {\r
+               (UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol ||\r
+                                      UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {\r
 \r
       return TRUE;\r
     }\r
@@ -985,16 +982,15 @@ MatchUsbClass (
 \r
 /**\r
   Check whether usb device, whose interface is UsbIf, matches the usb WWID requirement which indicated by\r
-  UsbWWIDDevicePathPtr whose is a short form usb WWID device path\r
+  UsbWWIDDevicePathPtr whose is a short form usb WWID device path.\r
 \r
-  @param UsbClassDevicePathPtr   a short form usb WWID device path\r
-  @param UsbIf                   a usb device interface\r
+  @param UsbWWIDDevicePathPtr    a short form usb WWID device path.\r
+  @param UsbIf                   a usb device interface.\r
 \r
-  @retval TRUE                   the usb device match the usb WWID requirement\r
-  @retval FALSE                  the usb device does not match the usb WWID requirement\r
+  @retval TRUE                   the usb device match the usb WWID requirement.\r
+  @retval FALSE                  the usb device does not match the usb WWID requirement.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 MatchUsbWwid (\r
   IN USB_WWID_DEVICE_PATH       *UsbWWIDDevicePathPtr,\r
@@ -1043,12 +1039,12 @@ MatchUsbWwid (
 }\r
 \r
 /**\r
-  Free a DEVICE_PATH_LIST_ITEM list\r
+  Free a DEVICE_PATH_LIST_ITEM list.\r
 \r
-  @param UsbIoDPList  a DEVICE_PATH_LIST_ITEM list pointer\r
+  @param  UsbIoDPList            a DEVICE_PATH_LIST_ITEM list pointer.\r
 \r
-  @retval EFI_INVALID_PARAMETER\r
-  @retval EFI_SUCCESS\r
+  @retval EFI_INVALID_PARAMETER  If parameters are invalid, return this value.\r
+  @retval EFI_SUCCESS            If free operation is successful, return this value.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1090,14 +1086,13 @@ UsbBusFreeUsbDPList (
 \r
 /**\r
   Store a wanted usb child device info (its Usb part of device path) which is indicated by\r
-  RemainingDevicePath in a Usb bus which  is indicated by UsbBusId\r
+  RemainingDevicePath in a Usb bus which  is indicated by UsbBusId.\r
 \r
-  @param UsbBusId              Point to EFI_USB_BUS_PROTOCOL interface\r
-  @param RemainingDevicePath   The remaining device patch\r
+  @param  UsbBusId               Point to EFI_USB_BUS_PROTOCOL interface.\r
+  @param  RemainingDevicePath    The remaining device patch.\r
 \r
-  @retval EFI_SUCCESS\r
-  @retval EFI_INVALID_PARAMETER\r
-  @retval EFI_OUT_OF_RESOURCES\r
+  @retval EFI_SUCCESS            Add operation is successful.\r
+  @retval EFI_INVALID_PARAMETER  The parameters are invalid.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1154,14 +1149,13 @@ UsbBusAddWantedUsbIoDP (
 }\r
 \r
 /**\r
-  Check whether a usb child  device is the wanted device in a bus\r
+  Check whether a usb child device is the wanted device in a bus.\r
 \r
-  @param Bus      The Usb bus's private data pointer\r
-  @param UsbIf    The usb child  device inferface\r
+  @param  Bus     The Usb bus's private data pointer.\r
+  @param  UsbIf   The usb child device inferface.\r
 \r
-  @retval EFI_SUCCESS\r
-  @retval EFI_INVALID_PARAMETER\r
-  @retval EFI_OUT_OF_RESOURCES\r
+  @retval True    If a usb child device is the wanted device in a bus.\r
+  @retval False   If a usb child device is *NOT* the wanted device in a bus.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1261,13 +1255,12 @@ UsbBusIsWantedUsbIO (
 \r
 /**\r
   Recursively connnect every wanted usb child device to ensure they all fully connected.\r
-  Check all the child Usb IO handles in this bus, recursively connecte if it is wanted usb child device\r
+  Check all the child Usb IO handles in this bus, recursively connecte if it is wanted usb child device.\r
 \r
-  @param UsbBusId   point to EFI_USB_BUS_PROTOCOL interface\r
+  @param  UsbBusId                  Point to EFI_USB_BUS_PROTOCOL interface.\r
 \r
-  @retval EFI_SUCCESS\r
-  @retval EFI_INVALID_PARAMETER\r
-  @retval EFI_OUT_OF_RESOURCES\r
+  @retval EFI_SUCCESS               Connect is done successfully.\r
+  @retval EFI_INVALID_PARAMETER     The parameter is invalid.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1337,10 +1330,10 @@ UsbBusRecursivelyConnectWantedUsbIo (
         //\r
         // Recursively connect the wanted Usb Io handle\r
         //\r
-        DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", UsbGetCurrentTpl ()));\r
+        DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ()));\r
         Status            = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);\r
         UsbIf->IsManaged  = (BOOLEAN)!EFI_ERROR (Status);\r
-        DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", UsbGetCurrentTpl()));\r
+        DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));\r
       }\r
     }\r
   }\r