]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Check Library usage and fix some typo.
authorgikidy <gikidy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Dec 2008 08:42:24 +0000 (08:42 +0000)
committergikidy <gikidy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Dec 2008 08:42:24 +0000 (08:42 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7137 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c

index 2e5edeb0c3e985b0e162444b866c240473f904d9..b2a70d13811bccfb39fa787ab1e812a424a589b4 100644 (file)
@@ -61,7 +61,7 @@ EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {
   @param  UsbStatus              USB result\r
 \r
   @retval EFI_INVALID_PARAMETER  The parameters are invalid\r
-  @retval EFI_SUCCESS            The control transfer succeded.\r
+  @retval EFI_SUCCESS            The control transfer succeeded.\r
   @retval Others                 Failed to execute the transfer\r
 \r
 **/\r
@@ -152,7 +152,7 @@ UsbIoControlTransfer (
   // should stop use its current UsbIo after calling this driver. The old\r
   // UsbIo will be uninstalled and new UsbIo be installed. We can't use\r
   // ReinstallProtocol since interfaces in different configuration may be\r
-  // completely irrellvant.\r
+  // completely irrelevant.\r
   //\r
   if ((Request->Request == USB_REQ_SET_CONFIG) &&\r
       (Request->RequestType == USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD,\r
@@ -924,13 +924,13 @@ UsbBusBuildProtocol (
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to open device path %r\n", Status));\r
 \r
-    gBS->FreePool (UsbBus);\r
+    FreePool (UsbBus);\r
     return Status;\r
   }\r
 \r
   //\r
   // Get USB_HC2/USB_HC host controller protocol (EHCI/UHCI).\r
-  // This is for backward compatbility with EFI 1.x. In UEFI\r
+  // This is for backward compatibility with EFI 1.x. In UEFI\r
   // 2.x, USB_HC2 replaces USB_HC. We will open both USB_HC2\r
   // and USB_HC because EHCI driver will install both protocols\r
   // (for the same reason). If we don't consume both of them,\r
@@ -965,7 +965,7 @@ UsbBusBuildProtocol (
   UsbHcSetState (UsbBus, EfiUsbHcStateOperational);\r
 \r
   //\r
-  // Install an EFI_USB_BUS_PROTOCOL to host controler to identify it.\r
+  // Install an EFI_USB_BUS_PROTOCOL to host controller to identify it.\r
   //\r
   Status = gBS->InstallProtocolInterface (\r
                   &Controller,\r
@@ -998,7 +998,7 @@ UsbBusBuildProtocol (
   RootIf = AllocateZeroPool (sizeof (USB_INTERFACE));\r
 \r
   if (RootIf == NULL) {\r
-    gBS->FreePool (RootHub);\r
+    FreePool (RootHub);\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto FREE_ROOTHUB;\r
   }\r
@@ -1024,10 +1024,10 @@ UsbBusBuildProtocol (
 \r
 FREE_ROOTHUB:\r
   if (RootIf != NULL) {\r
-    gBS->FreePool (RootIf);\r
+    FreePool (RootIf);\r
   }\r
   if (RootHub != NULL) {\r
-    gBS->FreePool (RootHub);\r
+    FreePool (RootHub);\r
   }\r
 \r
 UNINSTALL_USBBUS:\r
@@ -1056,7 +1056,7 @@ CLOSE_HC:
          This->DriverBindingHandle,\r
          Controller\r
          );\r
-  gBS->FreePool (UsbBus);\r
+  FreePool (UsbBus);\r
 \r
   DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to start bus driver %r\n", Status));\r
   return Status;\r
@@ -1251,7 +1251,7 @@ UsbBusControllerDriverStart (
 \r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // If first start, build the bus execute enviorment and install bus protocol\r
+    // If first start, build the bus execute environment and install bus protocol\r
     //\r
     Status = UsbBusBuildProtocol (This, Controller, RemainingDevicePath);\r
     if (EFI_ERROR (Status)) {\r
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
index 0904e72a65d44726d6491642ae1fa0dce77c853c..46be2df40e4b4e27336a998f23562ae37a691454 100644 (file)
@@ -32,9 +32,12 @@ UsbGetEndpointDesc (
   )\r
 {\r
   USB_ENDPOINT_DESC       *EpDesc;\r
-  UINTN                   Index;\r
-\r
-  for (Index = 0; Index < UsbIf->IfSetting->Desc.NumEndpoints; Index++) {\r
+  UINT8                   Index;\r
+  UINT8                   NumEndpoints;\r
+  \r
+  NumEndpoints = UsbIf->IfSetting->Desc.NumEndpoints;\r
+  \r
+  for (Index = 0; Index < NumEndpoints; Index++) {\r
     EpDesc = UsbIf->IfSetting->Endpoints[Index];\r
 \r
     if (EpDesc->Desc.EndpointAddress == EpAddr) {\r
@@ -71,10 +74,10 @@ UsbFreeInterface (
          );\r
 \r
   if (UsbIf->DevicePath != NULL) {\r
-    gBS->FreePool (UsbIf->DevicePath);\r
+    FreePool (UsbIf->DevicePath);\r
   }\r
 \r
-  gBS->FreePool (UsbIf);\r
+  FreePool (UsbIf);\r
 }\r
 \r
 \r
@@ -175,10 +178,10 @@ UsbCreateInterface (
 \r
 ON_ERROR:\r
   if (UsbIf->DevicePath != NULL) {\r
-    gBS->FreePool (UsbIf->DevicePath);\r
+    FreePool (UsbIf->DevicePath);\r
   }\r
 \r
-  gBS->FreePool (UsbIf);\r
+  FreePool (UsbIf);\r
   return NULL;\r
 }\r
 \r
@@ -240,7 +243,7 @@ UsbCreateDevice (
 \r
 /**\r
   Connect the USB interface with its driver. EFI USB bus will\r
-  create a USB interface for each seperate interface descriptor.\r
+  create a USB interface for each separate interface descriptor.\r
 \r
   @param  UsbIf             The interface to connect driver to.\r
 \r
index fdcde5d90f76231b8203de9c084d506f26016e73..ac893e4e2a4d021425dd2b3b0263e3d67dac03f6 100644 (file)
@@ -252,7 +252,7 @@ UsbHubCtrlGetHubStatus (
   @param  State                 Variable to return the hub port state.\r
 \r
   @retval EFI_SUCCESS           The port state is returned in State.\r
-  @retval Others                Failed to retrive the port state.\r
+  @retval Others                Failed to retrieve the port state.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -627,6 +627,7 @@ UsbHubInit (
   USB_DEVICE              *HubDev;\r
   EFI_STATUS              Status;\r
   UINT8                   Index;\r
+  UINT8                   NumEndpoints;\r
 \r
   //\r
   // Locate the interrupt endpoint for port change map\r
@@ -635,8 +636,9 @@ UsbHubInit (
   Setting       = HubIf->IfSetting;\r
   HubDev        = HubIf->Device;\r
   EpDesc        = NULL;\r
+  NumEndpoints  = Setting->Desc.NumEndpoints;\r
 \r
-  for (Index = 0; Index < Setting->Desc.NumEndpoints; Index++) {\r
+  for (Index = 0; Index < NumEndpoints; Index++) {\r
     ASSERT ((Setting->Endpoints != NULL) && (Setting->Endpoints[Index] != NULL));\r
 \r
     EpDesc = Setting->Endpoints[Index];\r
@@ -647,7 +649,7 @@ UsbHubInit (
     }\r
   }\r
 \r
-  if (Index == Setting->Desc.NumEndpoints) {\r
+  if (Index == NumEndpoints) {\r
     DEBUG (( EFI_D_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));\r
     return EFI_DEVICE_ERROR;\r
   }\r
@@ -862,7 +864,7 @@ UsbHubClearPortFeature (
 \r
 \r
 /**\r
-  Interface funtion to reset the port.\r
+  Interface function to reset the port.\r
 \r
   @param  HubIf                 The hub interface.\r
   @param  Port                  The port to reset.\r
@@ -964,7 +966,7 @@ UsbHubRelease (
 \r
   @param  HubIf                 The root hub interface.\r
 \r
-  @retval EFI_SUCCESS           The interface is initialied for root hub.\r
+  @retval EFI_SUCCESS           The interface is initialized for root hub.\r
   @retval Others                Failed to initialize the hub.\r
 \r
 **/\r
@@ -1155,7 +1157,7 @@ UsbRootHubClearPortFeature (
 \r
 \r
 /**\r
-  Interface funtion to reset the root hub port.\r
+  Interface function to reset the root hub port.\r
 \r
   @param  RootIf                The root hub interface.\r
   @param  Port                  The port to reset.\r