@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
// 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
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
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
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
\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
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
\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
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
}\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
}\r
}\r
\r
- gBS->FreePool (DevDesc->Configs);\r
+ FreePool (DevDesc->Configs);\r
}\r
\r
- gBS->FreePool (DevDesc);\r
+ FreePool (DevDesc);\r
}\r
\r
\r
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
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
\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
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
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
);\r
\r
if (EFI_ERROR (Status)) {\r
- gBS->FreePool (Buf);\r
+ FreePool (Buf);\r
return NULL;\r
}\r
\r
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
\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
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
\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
)\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
);\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
\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
\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
@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
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
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
}\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
\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
\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
\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