]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeMdeModulePkg/Xhci: Fix a wrong conditional judgment which bring assertion with...
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Dec 2012 06:31:41 +0000 (06:31 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Dec 2012 06:31:41 +0000 (06:31 +0000)
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Elvin Li <elvin.li@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14021 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c

index e03934fa097f55c6b206c7d28c1e8f110b053792..b8a1d78a7e8b83983e5b7ecd035da21d1c778003 100644 (file)
@@ -140,27 +140,27 @@ XhcReset (
   )
 {
   USB_XHCI_INSTANCE  *Xhc;
-  EFI_STATUS         Status;\r
-  EFI_TPL            OldTpl;\r
-\r
-  Xhc = XHC_FROM_THIS (This);\r
-  \r
-  if (Xhc->DevicePath != NULL) {\r
-    //\r
-    // Report Status Code to indicate reset happens\r
-    //\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_PROGRESS_CODE,\r
-      (EFI_IO_BUS_USB | EFI_IOB_PC_RESET),\r
-      Xhc->DevicePath\r
-      );\r
-  }  \r
-\r
-  OldTpl = gBS->RaiseTPL (XHC_TPL);\r
-\r
-  switch (Attributes) {\r
-  case EFI_USB_HC_RESET_GLOBAL:\r
-  //\r
+  EFI_STATUS         Status;
+  EFI_TPL            OldTpl;
+
+  Xhc = XHC_FROM_THIS (This);
+  
+  if (Xhc->DevicePath != NULL) {
+    //
+    // Report Status Code to indicate reset happens
+    //
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+      EFI_PROGRESS_CODE,
+      (EFI_IO_BUS_USB | EFI_IOB_PC_RESET),
+      Xhc->DevicePath
+      );
+  }  
+
+  OldTpl = gBS->RaiseTPL (XHC_TPL);
+
+  switch (Attributes) {
+  case EFI_USB_HC_RESET_GLOBAL:
+  //
   // Flow through, same behavior as Host Controller Reset
   //
   case EFI_USB_HC_RESET_HOST_CONTROLLER:
@@ -932,9 +932,9 @@ XhcControlTransfer (
         }
         Xhc->UsbDevContext[SlotId].ConfDesc = AllocateZeroPool (Xhc->UsbDevContext[SlotId].DevDesc.NumConfigurations * sizeof (EFI_USB_CONFIG_DESCRIPTOR *));
         if (Xhc->HcCParams.Data.Csz == 0) {
-          Status = XhcEvaluateContext (Xhc, SlotId, MaxPacket0);
+          Status = XhcEvaluateContext (Xhc, SlotId, MaxPacket0);\r
         } else {
-          Status = XhcEvaluateContext64 (Xhc, SlotId, MaxPacket0);
+          Status = XhcEvaluateContext64 (Xhc, SlotId, MaxPacket0);\r
         }
         ASSERT_EFI_ERROR (Status);
     } else if (DescriptorType == USB_DESC_TYPE_CONFIG) {
@@ -1007,17 +1007,15 @@ XhcControlTransfer (
       if ((State & XHC_PORTSC_PS) >> 10 == 0) {
         PortStatus.PortStatus |= USB_PORT_STAT_SUPER_SPEED;
       }
-    } else if (DeviceSpeed == EFI_USB_SPEED_HIGH) {
+    } else {
       //
-      // For high speed hub, its bit9~10 presents the attached device speed.
+      // For high or full/low speed hub, its bit9~10 presents the attached device speed.
       //
       if (XHC_BIT_IS_SET (State, BIT9)) {
         PortStatus.PortStatus |= USB_PORT_STAT_LOW_SPEED;
       } else if (XHC_BIT_IS_SET (State, BIT10)) {
         PortStatus.PortStatus |= USB_PORT_STAT_HIGH_SPEED;
       }
-    } else {
-      ASSERT (0);
     }
 
     //
@@ -1690,15 +1688,15 @@ ON_EXIT:
   @return The allocated and initialized USB_XHCI_INSTANCE structure if created,
           otherwise NULL.
 
-**/\r
-USB_XHCI_INSTANCE*\r
-XhcCreateUsbHc (\r
-  IN EFI_PCI_IO_PROTOCOL       *PciIo,\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
-  IN UINT64                    OriginalPciAttributes\r
-  )\r
-{\r
-  USB_XHCI_INSTANCE       *Xhc;\r
+**/
+USB_XHCI_INSTANCE*
+XhcCreateUsbHc (
+  IN EFI_PCI_IO_PROTOCOL       *PciIo,
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath,
+  IN UINT64                    OriginalPciAttributes
+  )
+{
+  USB_XHCI_INSTANCE       *Xhc;
   EFI_STATUS              Status;
   UINT32                  PageSize;
   UINT16                  ExtCapReg;
@@ -1711,13 +1709,13 @@ XhcCreateUsbHc (
 
   //
   // Initialize private data structure
-  //\r
-  Xhc->Signature             = XHCI_INSTANCE_SIG;\r
-  Xhc->PciIo                 = PciIo;\r
-  Xhc->DevicePath            = DevicePath;\r
-  Xhc->OriginalPciAttributes = OriginalPciAttributes;\r
-  CopyMem (&Xhc->Usb2Hc, &gXhciUsb2HcTemplate, sizeof (EFI_USB2_HC_PROTOCOL));\r
-\r
+  //
+  Xhc->Signature             = XHCI_INSTANCE_SIG;
+  Xhc->PciIo                 = PciIo;
+  Xhc->DevicePath            = DevicePath;
+  Xhc->OriginalPciAttributes = OriginalPciAttributes;
+  CopyMem (&Xhc->Usb2Hc, &gXhciUsb2HcTemplate, sizeof (EFI_USB2_HC_PROTOCOL));
+
   InitializeListHead (&Xhc->AsyncIntTransfers);
 
   //
@@ -1841,13 +1839,13 @@ XhcDriverBindingStart (
   EFI_STATUS              Status;
   EFI_PCI_IO_PROTOCOL     *PciIo;
   UINT64                  Supports;
-  UINT64                  OriginalPciAttributes;\r
-  BOOLEAN                 PciAttributesSaved;\r
-  USB_XHCI_INSTANCE       *Xhc;\r
-  EFI_DEVICE_PATH_PROTOCOL  *HcDevicePath;\r
-\r
-  //\r
-  // Open the PciIo Protocol, then enable the USB host controller\r
+  UINT64                  OriginalPciAttributes;
+  BOOLEAN                 PciAttributesSaved;
+  USB_XHCI_INSTANCE       *Xhc;
+  EFI_DEVICE_PATH_PROTOCOL  *HcDevicePath;
+
+  //
+  // Open the PciIo Protocol, then enable the USB host controller
   //
   Status = gBS->OpenProtocol (
                   Controller,
@@ -1859,25 +1857,25 @@ XhcDriverBindingStart (
                   );
 
   if (EFI_ERROR (Status)) {
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open Device Path Protocol for on USB host controller\r
-  //\r
-  HcDevicePath = NULL;\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &HcDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-\r
-  PciAttributesSaved = FALSE;\r
-  //\r
-  // Save original PCI attributes\r
+    return Status;
+  }
+
+  //
+  // Open Device Path Protocol for on USB host controller
+  //
+  HcDevicePath = NULL;
+  Status = gBS->OpenProtocol (
+                  Controller,
+                  &gEfiDevicePathProtocolGuid,
+                  (VOID **) &HcDevicePath,
+                  This->DriverBindingHandle,
+                  Controller,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+
+  PciAttributesSaved = FALSE;
+  //
+  // Save original PCI attributes
   //
   Status = PciIo->Attributes (
                     PciIo,
@@ -1912,13 +1910,13 @@ XhcDriverBindingStart (
     goto CLOSE_PCIIO;
   }
 
-  //\r
-  // Create then install USB2_HC_PROTOCOL\r
-  //\r
-  Xhc = XhcCreateUsbHc (PciIo, HcDevicePath, OriginalPciAttributes);\r
-\r
-  if (Xhc == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to create USB2_HC\n"));\r
+  //
+  // Create then install USB2_HC_PROTOCOL
+  //
+  Xhc = XhcCreateUsbHc (PciIo, HcDevicePath, OriginalPciAttributes);
+
+  if (Xhc == NULL) {
+    DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to create USB2_HC\n"));
     return EFI_OUT_OF_RESOURCES;
   }