]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBotPei / PeiUsbLib.c
index 2a8fde07ff9858d9d6de32dbadf0feb99d119bd7..4f20c711442cfdf2ddfafdf1f841d671a3c44f3b 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
 Common Libarary  for PEI USB.\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-  \r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 of the BSD License which accompanies this distribution.  The\r
@@ -215,15 +215,24 @@ PeiUsbClearEndpointHalt (
   IN UINT8                    EndpointAddress\r
   )\r
 {\r
-  EFI_STATUS                  Status;\r
-  PEI_USB_DEVICE              *PeiUsbDev;\r
-  EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;\r
-  UINT8                       EndpointIndex;\r
+  EFI_STATUS                    Status;\r
+  EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDesc;\r
+  EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDescriptor;\r
+  UINT8                         EndpointIndex;\r
 \r
-  EndpointIndex = 0;\r
-  PeiUsbDev     = PEI_USB_DEVICE_FROM_THIS (UsbIoPpi);\r
 \r
-  while (EndpointIndex < MAX_ENDPOINT) {\r
+  //\r
+  // Check its interface\r
+  //\r
+  Status = UsbIoPpi->UsbGetInterfaceDescriptor (\r
+                      PeiServices,\r
+                      UsbIoPpi,\r
+                      &InterfaceDesc\r
+                      );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  for (EndpointIndex = 0; EndpointIndex < InterfaceDesc->NumEndpoints; EndpointIndex++) {\r
     Status = UsbIoPpi->UsbGetEndpointDescriptor (PeiServices, UsbIoPpi, EndpointIndex, &EndpointDescriptor);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_INVALID_PARAMETER;\r
@@ -232,11 +241,9 @@ PeiUsbClearEndpointHalt (
     if (EndpointDescriptor->EndpointAddress == EndpointAddress) {\r
       break;\r
     }\r
-\r
-    EndpointIndex++;\r
   }\r
 \r
-  if (EndpointIndex == MAX_ENDPOINT) {\r
+  if (EndpointIndex == InterfaceDesc->NumEndpoints) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -248,13 +255,6 @@ PeiUsbClearEndpointHalt (
             EndpointAddress\r
             );\r
 \r
-  //\r
-  // set data toggle to zero.\r
-  //\r
-  if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {\r
-    PeiUsbDev->DataToggle = (UINT8) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));\r
-  }\r
-\r
   return Status;\r
 }\r
 \r