From 063bcff758e9d078dcaa6acfd2476a97176393ea Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Mon, 20 Feb 2017 14:25:13 +0800 Subject: [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable The patch doesn't impact functionality. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Hao A Wu --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index d9a83bee7c..81171c82d9 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -1341,7 +1341,6 @@ UpdatePciInfo ( { EFI_STATUS Status; UINTN BarIndex; - UINTN BarEndIndex; BOOLEAN SetFlag; VOID *Configuration; EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; @@ -1395,24 +1394,19 @@ UpdatePciInfo ( break; } - if ((Ptr->AddrTranslationOffset == MAX_UINT64) || (Ptr->AddrTranslationOffset == MAX_UINT8)) { - // - // Update all the bars in the device - // Compare against MAX_UINT8 is to keep backward compatibility. - // - BarIndex = 0; - BarEndIndex = PCI_MAX_BAR - 1; - } else { - BarIndex = (UINTN) Ptr->AddrTranslationOffset; - BarEndIndex = BarIndex; - } + for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) { + if ((Ptr->AddrTranslationOffset != MAX_UINT64) && + (Ptr->AddrTranslationOffset != MAX_UINT8) && + (Ptr->AddrTranslationOffset != BarIndex) + ) { + // + // Skip updating when AddrTranslationOffset is not MAX_UINT64 or MAX_UINT8 (wide match). + // Skip updating when current BarIndex doesn't equal to AddrTranslationOffset. + // Comparing against MAX_UINT8 is to keep backward compatibility. + // + continue; + } - if (BarIndex >= PCI_MAX_BAR) { - Ptr++; - continue; - } - - for (; BarIndex <= BarEndIndex; BarIndex++) { SetFlag = FALSE; switch (Ptr->ResType) { case ACPI_ADDRESS_SPACE_TYPE_MEM: