/* This is a convenience function that may save client code calls to  */
RETURN_STATUS EFIAPI PciCapListFindCapVersion(IN PCI_CAP_LIST *CapList, IN PCI_CAP_DOMAIN Domain, IN UINT16 CapId, IN UINT8 MinVersion, OUT PCI_CAP **Cap OPTIONAL)
/* This is a convenience function that may save client code calls to  */
RETURN_STATUS EFIAPI PciCapListFindCapVersion(IN PCI_CAP_LIST *CapList, IN PCI_CAP_DOMAIN Domain, IN UINT16 CapId, IN UINT8 MinVersion, OUT PCI_CAP **Cap OPTIONAL)
{
  PCI_CAP_KEY               Key;
  ORDERED_COLLECTION_ENTRY  *PciCapEntry;
  Key.Domain   = Domain;
  Key.CapId    = CapId;
  Key.Instance = 0;
  for (PciCapEntry = OrderedCollectionFind (CapList->Capabilities, &Key);
       PciCapEntry != NULL;
       PciCapEntry = OrderedCollectionNext (PciCapEntry))
  {
    PCI_CAP  *PciCap;
    PciCap = OrderedCollectionUserStruct (PciCapEntry);
    if ((PciCap->Key.Domain != Domain) || (PciCap->Key.CapId != CapId)) {
      break;
    }
    if (PciCap->Version >= MinVersion) {
      if (Cap != NULL) {
        *Cap = PciCap;
      }
      return RETURN_SUCCESS;
    }
  }
  return RETURN_NOT_FOUND;
}