From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AD0B882154 for ; Sun, 19 Feb 2017 22:25:45 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2017 22:25:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,184,1484035200"; d="scan'208";a="227372070" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 19 Feb 2017 22:25:44 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao A Wu Date: Mon, 20 Feb 2017 14:25:42 +0800 Message-Id: <20170220062542.456028-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Feb 2017 06:25:45 -0000 The patch doesn't impact functionality. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Hao A Wu --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index d9a83be..00b6622 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)) { + for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) { + if ((Ptr->AddrTranslationOffset != MAX_UINT64) && + (Ptr->AddrTranslationOffset != MAX_UINT8) && + (Ptr->AddrTranslationOffset != BarIndex) + ) { // - // Update all the bars in the device + // Skip updating when AddrTranslationOffset is MAX_UINT64 or MAX_UINT8 (wide match). + // SKip updating when current BarIndex doesn't equal to AddrTranslationOffset. // Compare against MAX_UINT8 is to keep backward compatibility. // - BarIndex = 0; - BarEndIndex = PCI_MAX_BAR - 1; - } else { - BarIndex = (UINTN) Ptr->AddrTranslationOffset; - BarEndIndex = BarIndex; - } - - if (BarIndex >= PCI_MAX_BAR) { - Ptr++; - continue; - } + continue; + } - for (; BarIndex <= BarEndIndex; BarIndex++) { SetFlag = FALSE; switch (Ptr->ResType) { case ACPI_ADDRESS_SPACE_TYPE_MEM: -- 2.9.0.windows.1