/* Remove rejected pci device from specific root bridge handle. */
VOID RemoveRejectedPciDevices(IN EFI_HANDLE RootBridgeHandle, IN PCI_IO_DEVICE *Bridge)
/* Remove rejected pci device from specific root bridge handle. */
VOID RemoveRejectedPciDevices(IN EFI_HANDLE RootBridgeHandle, IN PCI_IO_DEVICE *Bridge)
{
  PCI_IO_DEVICE  *Temp;
  LIST_ENTRY     *CurrentLink;
  LIST_ENTRY     *LastLink;
  if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
    return;
  }
  CurrentLink = Bridge->ChildList.ForwardLink;
  while (CurrentLink != NULL && CurrentLink != &Bridge->ChildList) {
    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
    if (IS_PCI_BRIDGE (&Temp->Pci)) {
      RemoveRejectedPciDevices (RootBridgeHandle, Temp);
    } else {
      if (IsPciDeviceRejected (Temp)) {
        if (!IsListEmpty (&Temp->ChildList)) {
          RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp);
        }
        LastLink = CurrentLink->BackLink;
        RemoveEntryList (CurrentLink);
        FreePciDevice (Temp);
        CurrentLink = LastLink;
      }
    }
    CurrentLink = CurrentLink->ForwardLink;
  }
}