public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable
@ 2017-02-20  6:25 Ruiyu Ni
  2017-02-20  6:38 ` Wu, Hao A
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2017-02-20  6:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao A Wu

The patch doesn't impact functionality.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
 .../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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable
  2017-02-20  6:25 [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable Ruiyu Ni
@ 2017-02-20  6:38 ` Wu, Hao A
  0 siblings, 0 replies; 2+ messages in thread
From: Wu, Hao A @ 2017-02-20  6:38 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

Some minor comments below.

With the changes:
Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu
> Ni
> Sent: Monday, February 20, 2017 2:26 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A
> Subject: [edk2] [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 <ruiyu.ni@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> ---
>  .../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).

According to the codes, the comment should be:
Skip updating when TranslationOffset is not MAX_UINT64 or MAX_UINT8 (wide
match).
Right?

> +      // SKip updating when current BarIndex doesn't equal to

Please fix 'SKip' as 'Skip'.

> 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-20  6:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-20  6:25 [PATCH] MdeModulePkg/PciBusDxe: Refine code to make it more readable Ruiyu Ni
2017-02-20  6:38 ` Wu, Hao A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox