pci: Get rid of magic number in AMD bus discovery
PATCH 1/1 pci: Get rid of magic number in AMD bus discovery
The number 4 is hardcoded in a couple of loops. Use the already-defined PCI_ROOT_NR macro instead.
--- arch/x86/pci/amd_bus.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/amd_bus.c +2 -2
@@ -332,7 +332,7 @@ static int __init early_fill_mp_bus_info(void)return 0 ; pci_root_num =0 ; -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) {int min_bus;int max_bus; reg =read_pci_config (bus, slot,1 ,0xe0 + (i <<2 ));
@@ -368,7 +368,7 @@ static int __init early_fill_mp_bus_info(void)memset (range,0 ,sizeof (range)); range[0 ].end =0xffff ;/* io port resource */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) { reg =read_pci_config (bus, slot,1 ,0xc0 + (i <<3 ));if (!(reg &3 ))continue ;
Signature · 1 line
1.6.3.3
Quoted 22 lines · dann frazier
The number 4 is hardcoded in a couple of loops. Use the already-defined
PCI_ROOT_NRmacro instead.Signed-off-by dann frazier <[email protected]>--- arch/x86/pci/amd_bus.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/x86/pci/amd_bus.c +1
-1@@ -332,7 +332,7 @@ static int __init early_fill_mp_bus_info(void)return 0 ; pci_root_num =0 ; -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) {int min_bus;int max_bus; reg =read_pci_config (bus, slot,1 ,0xe0 + (i <<2 ));
arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info(void) · line 374
Quoted 8 lines
arch/x86/pci/amd_bus.c +1
-1@@ -368,7 +368,7 @@ static int __init early_fill_mp_bus_info(void)memset (range,0 ,sizeof (range)); range[0 ].end =0xffff ;/* io port resource */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) { reg =read_pci_config (bus, slot,1 ,0xc0 + (i <<3 ));if (!(reg &3 ))continue ;
please don't do that.
how about
/* mmio resource */
for (i = 0; i < 8; i++) {those value is decided by HW...
YH
Quoted 34 lines · Yinghai Lu
Quoted 22 lines · dann frazier
The number 4 is hardcoded in a couple of loops. Use the already-defined
PCI_ROOT_NRmacro instead.Signed-off-by dann frazier <[email protected]>--- arch/x86/pci/amd_bus.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/x86/pci/amd_bus.c +1
-1@@ -332,7 +332,7 @@ static int __init early_fill_mp_bus_info(void)return 0 ; pci_root_num =0 ; -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) {int min_bus;int max_bus; reg =read_pci_config (bus, slot,1 ,0xe0 + (i <<2 ));arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info(void) · line 374
Quoted 8 lines
arch/x86/pci/amd_bus.c +1
-1@@ -368,7 +368,7 @@ static int __init early_fill_mp_bus_info(void)memset (range,0 ,sizeof (range)); range[0 ].end =0xffff ;/* io port resource */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_ROOT_NR ; i++) { reg =read_pci_config (bus, slot,1 ,0xc0 + (i <<3 ));if (!(reg &3 ))continue ;please don't do that.
Quoted 5 lines
how about
/* mmio resource */ for (i = 0; i < 8; i++) {those value is decided by HW...
Sorry, I don't follow.
My goal was just to remove the magic '4' number and replace it with a macro instead - not to bump it up. PCI_ROOT_NR looked like the right value (used in declaring the array we are indexing), but if not maybe some other macro should be defined?
Signature · 1 line
dann frazier