]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
Check Library usage and fix some typo.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbDesc.c
index 0e9ea1e4d329a1f0c8010c7cb4f80e755a8a467f..e18d7559bb2ec1f79b25106c9e87ef9a8a951245 100644 (file)
@@ -40,14 +40,14 @@ UsbFreeInterfaceDesc (
       Ep = Setting->Endpoints[Index];\r
 \r
       if (Ep != NULL) {\r
-        gBS->FreePool (Ep);\r
+        FreePool (Ep);\r
       }\r
     }\r
 \r
-    gBS->FreePool (Setting->Endpoints);\r
+    FreePool (Setting->Endpoints);\r
   }\r
 \r
-  gBS->FreePool (Setting);\r
+  FreePool (Setting);\r
 }\r
 \r
 \r
@@ -89,13 +89,13 @@ UsbFreeConfigDesc (
         }\r
       }\r
 \r
-      gBS->FreePool (Interface);\r
+      FreePool (Interface);\r
     }\r
 \r
-    gBS->FreePool (Config->Interfaces);\r
+    FreePool (Config->Interfaces);\r
   }\r
 \r
-  gBS->FreePool (Config);\r
+  FreePool (Config);\r
 \r
 }\r
 \r
@@ -122,10 +122,10 @@ UsbFreeDevDesc (
       }\r
     }\r
 \r
-    gBS->FreePool (DevDesc->Configs);\r
+    FreePool (DevDesc->Configs);\r
   }\r
 \r
-  gBS->FreePool (DevDesc);\r
+  FreePool (DevDesc);\r
 }\r
 \r
 \r
@@ -133,7 +133,7 @@ UsbFreeDevDesc (
   Create a descriptor.\r
 \r
   @param  DescBuf               The buffer of raw descriptor.\r
-  @param  Len                   The lenght of the raw descriptor buffer.\r
+  @param  Len                   The length of the raw descriptor buffer.\r
   @param  Type                  The type of descriptor to create.\r
   @param  Consumed              Number of bytes consumed.\r
 \r
@@ -198,13 +198,10 @@ UsbCreateDesc (
     return NULL;\r
   }\r
 \r
-  Desc = AllocateZeroPool (CtrlLen);\r
-\r
+  Desc = AllocateCopyPool(CtrlLen, Head);\r
   if (Desc == NULL) {\r
     return NULL;\r
   }\r
-\r
-  CopyMem (Desc, Head, DescLen);\r
   *Consumed = Offset + Head->Len;\r
 \r
   return Desc;\r
@@ -212,10 +209,10 @@ UsbCreateDesc (
 \r
 \r
 /**\r
-  Parse an interface desciptor and its endpoints.\r
+  Parse an interface descriptor and its endpoints.\r
 \r
   @param  DescBuf               The buffer of raw descriptor.\r
-  @param  Len                   The lenght of the raw descriptor buffer.\r
+  @param  Len                   The length of the raw descriptor buffer.\r
   @param  Consumed              The number of raw descriptor consumed.\r
 \r
   @return The create interface setting or NULL if failed.\r
@@ -246,7 +243,7 @@ UsbParseInterfaceDesc (
   Offset = Used;\r
 \r
   //\r
-  // Create an arry to hold the interface's endpoints\r
+  // Create an array to hold the interface's endpoints\r
   //\r
   NumEp  = Setting->Desc.NumEndpoints;\r
 \r
@@ -293,7 +290,7 @@ ON_ERROR:
   Parse the configuration descriptor and its interfaces.\r
 \r
   @param  DescBuf               The buffer of raw descriptor.\r
-  @param  Len                   The lenght of the raw descriptor buffer.\r
+  @param  Len                   The length of the raw descriptor buffer.\r
 \r
   @return The created configuration descriptor.\r
 \r
@@ -631,7 +628,7 @@ UsbGetOneString (
              );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (Buf);\r
+    FreePool (Buf);\r
     return NULL;\r
   }\r
 \r
@@ -675,8 +672,8 @@ UsbBuildLangTable (
   Status = EFI_SUCCESS;\r
 \r
   Max   = (Desc->Length - 2) / 2;\r
-  Max   = (Max < USB_MAX_LANG_ID ? Max : USB_MAX_LANG_ID);\r
-\r
+  Max   = MIN(Max, USB_MAX_LANG_ID);\r
+  \r
   Point = Desc->String;\r
   for (Index = 0; Index < Max; Index++) {\r
     UsbDev->LangId[Index] = *Point;\r
@@ -693,7 +690,7 @@ ON_EXIT:
 \r
 /**\r
   Retrieve the indexed configure for the device. USB device\r
-  returns the configuration togetther with the interfaces for\r
+  returns the configuration together with the interfaces for\r
   this configuration. Configuration descriptor is also of\r
   variable length.\r
 \r
@@ -739,7 +736,7 @@ UsbGetOneConfig (
   if (EFI_ERROR (Status)) {\r
     DEBUG (( EFI_D_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));\r
 \r
-    gBS->FreePool (Buf);\r
+    FreePool (Buf);\r
     return NULL;\r
   }\r
 \r
@@ -813,7 +810,7 @@ UsbBuildDescTable (
 \r
     ConfigDesc = UsbParseConfigDesc ((UINT8 *) Config, Config->TotalLength);\r
 \r
-    gBS->FreePool (Config);\r
+    FreePool (Config);\r
 \r
     if (ConfigDesc == NULL) {\r
       DEBUG (( EFI_D_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));\r