diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2015-03-12 16:07:04 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2015-03-19 11:17:22 -0400 |
commit | 9e808eb6a7689b61399f772a2576d779161769ec (patch) | |
tree | 73af8c5605ba91394b1fffdc964a03741b4897c4 | |
parent | a0c8a4d9f92d1ecd053eaa0e6cde7b4f24af97a8 (diff) |
PCI: Cleanup control flow
Return errors immediately so the straightline path is the normal,
no-error path. No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | arch/arm/mach-dove/pcie.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-mv78xx0/pcie.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/pci.c | 32 | ||||
-rw-r--r-- | arch/mips/pci/pci.c | 33 | ||||
-rw-r--r-- | arch/sh/drivers/pci/pci.c | 26 | ||||
-rw-r--r-- | arch/sparc/kernel/leon_pci.c | 17 |
6 files changed, 62 insertions, 70 deletions
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c index 8a275f297522..91fe97144570 100644 --- a/arch/arm/mach-dove/pcie.c +++ b/arch/arm/mach-dove/pcie.c | |||
@@ -155,17 +155,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup); | |||
155 | static struct pci_bus __init * | 155 | static struct pci_bus __init * |
156 | dove_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 156 | dove_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
157 | { | 157 | { |
158 | struct pci_bus *bus; | 158 | if (nr >= num_pcie_ports) { |
159 | |||
160 | if (nr < num_pcie_ports) { | ||
161 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
162 | &sys->resources); | ||
163 | } else { | ||
164 | bus = NULL; | ||
165 | BUG(); | 159 | BUG(); |
160 | return NULL; | ||
166 | } | 161 | } |
167 | 162 | ||
168 | return bus; | 163 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, |
164 | &sys->resources); | ||
169 | } | 165 | } |
170 | 166 | ||
171 | static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 167 | static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c index 445e553f4a28..097ea4cb1136 100644 --- a/arch/arm/mach-mv78xx0/pcie.c +++ b/arch/arm/mach-mv78xx0/pcie.c | |||
@@ -197,17 +197,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup); | |||
197 | static struct pci_bus __init * | 197 | static struct pci_bus __init * |
198 | mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 198 | mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
199 | { | 199 | { |
200 | struct pci_bus *bus; | 200 | if (nr >= num_pcie_ports) { |
201 | |||
202 | if (nr < num_pcie_ports) { | ||
203 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
204 | &sys->resources); | ||
205 | } else { | ||
206 | bus = NULL; | ||
207 | BUG(); | 201 | BUG(); |
202 | return NULL; | ||
208 | } | 203 | } |
209 | 204 | ||
210 | return bus; | 205 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, |
206 | &sys->resources); | ||
211 | } | 207 | } |
212 | 208 | ||
213 | static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot, | 209 | static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot, |
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c index 87a12d6930ff..b02f3947be51 100644 --- a/arch/arm/mach-orion5x/pci.c +++ b/arch/arm/mach-orion5x/pci.c | |||
@@ -540,37 +540,33 @@ void __init orion5x_pci_set_cardbus_mode(void) | |||
540 | 540 | ||
541 | int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys) | 541 | int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys) |
542 | { | 542 | { |
543 | int ret = 0; | ||
544 | |||
545 | vga_base = ORION5X_PCIE_MEM_PHYS_BASE; | 543 | vga_base = ORION5X_PCIE_MEM_PHYS_BASE; |
546 | 544 | ||
547 | if (nr == 0) { | 545 | if (nr == 0) { |
548 | orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr); | 546 | orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr); |
549 | ret = pcie_setup(sys); | 547 | return pcie_setup(sys); |
550 | } else if (nr == 1 && !orion5x_pci_disabled) { | 548 | } |
549 | |||
550 | if (nr == 1 && !orion5x_pci_disabled) { | ||
551 | orion5x_pci_set_bus_nr(sys->busnr); | 551 | orion5x_pci_set_bus_nr(sys->busnr); |
552 | ret = pci_setup(sys); | 552 | return pci_setup(sys); |
553 | } | 553 | } |
554 | 554 | ||
555 | return ret; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys) | 558 | struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys) |
559 | { | 559 | { |
560 | struct pci_bus *bus; | 560 | if (nr == 0) |
561 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
562 | &sys->resources); | ||
561 | 563 | ||
562 | if (nr == 0) { | 564 | if (nr == 1 && !orion5x_pci_disabled) |
563 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | 565 | return pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys, |
564 | &sys->resources); | 566 | &sys->resources); |
565 | } else if (nr == 1 && !orion5x_pci_disabled) { | ||
566 | bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys, | ||
567 | &sys->resources); | ||
568 | } else { | ||
569 | bus = NULL; | ||
570 | BUG(); | ||
571 | } | ||
572 | 567 | ||
573 | return bus; | 568 | BUG(); |
569 | return NULL; | ||
574 | } | 570 | } |
575 | 571 | ||
576 | int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 572 | int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 9eb54b557c9f..8bb13a4af68a 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -94,28 +94,29 @@ static void pcibios_scanbus(struct pci_controller *hose) | |||
94 | pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); | 94 | pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); |
95 | bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, | 95 | bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, |
96 | &resources); | 96 | &resources); |
97 | if (!bus) | ||
98 | pci_free_resource_list(&resources); | ||
99 | |||
100 | hose->bus = bus; | 97 | hose->bus = bus; |
101 | 98 | ||
102 | need_domain_info = need_domain_info || hose->index; | 99 | need_domain_info = need_domain_info || hose->index; |
103 | hose->need_domain_info = need_domain_info; | 100 | hose->need_domain_info = need_domain_info; |
104 | if (bus) { | ||
105 | next_busno = bus->busn_res.end + 1; | ||
106 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
107 | reserve some space for bridges. */ | ||
108 | if (next_busno > 224) { | ||
109 | next_busno = 0; | ||
110 | need_domain_info = 1; | ||
111 | } | ||
112 | 101 | ||
113 | if (!pci_has_flag(PCI_PROBE_ONLY)) { | 102 | if (!bus) { |
114 | pci_bus_size_bridges(bus); | 103 | pci_free_resource_list(&resources); |
115 | pci_bus_assign_resources(bus); | 104 | return; |
116 | } | 105 | } |
117 | pci_bus_add_devices(bus); | 106 | |
107 | next_busno = bus->busn_res.end + 1; | ||
108 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
109 | reserve some space for bridges. */ | ||
110 | if (next_busno > 224) { | ||
111 | next_busno = 0; | ||
112 | need_domain_info = 1; | ||
113 | } | ||
114 | |||
115 | if (!pci_has_flag(PCI_PROBE_ONLY)) { | ||
116 | pci_bus_size_bridges(bus); | ||
117 | pci_bus_assign_resources(bus); | ||
118 | } | 118 | } |
119 | pci_bus_add_devices(bus); | ||
119 | } | 120 | } |
120 | 121 | ||
121 | #ifdef CONFIG_OF | 122 | #ifdef CONFIG_OF |
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index efc10519916a..d5462b7bc514 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c | |||
@@ -58,21 +58,23 @@ static void pcibios_scanbus(struct pci_channel *hose) | |||
58 | 58 | ||
59 | need_domain_info = need_domain_info || hose->index; | 59 | need_domain_info = need_domain_info || hose->index; |
60 | hose->need_domain_info = need_domain_info; | 60 | hose->need_domain_info = need_domain_info; |
61 | if (bus) { | ||
62 | next_busno = bus->busn_res.end + 1; | ||
63 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
64 | reserve some space for bridges. */ | ||
65 | if (next_busno > 224) { | ||
66 | next_busno = 0; | ||
67 | need_domain_info = 1; | ||
68 | } | ||
69 | 61 | ||
70 | pci_bus_size_bridges(bus); | 62 | if (!bus) { |
71 | pci_bus_assign_resources(bus); | ||
72 | pci_bus_add_devices(bus); | ||
73 | } else { | ||
74 | pci_free_resource_list(&resources); | 63 | pci_free_resource_list(&resources); |
64 | return; | ||
65 | } | ||
66 | |||
67 | next_busno = bus->busn_res.end + 1; | ||
68 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
69 | reserve some space for bridges. */ | ||
70 | if (next_busno > 224) { | ||
71 | next_busno = 0; | ||
72 | need_domain_info = 1; | ||
75 | } | 73 | } |
74 | |||
75 | pci_bus_size_bridges(bus); | ||
76 | pci_bus_assign_resources(bus); | ||
77 | pci_bus_add_devices(bus); | ||
76 | } | 78 | } |
77 | 79 | ||
78 | /* | 80 | /* |
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c index 297107679fdf..4371f72ff025 100644 --- a/arch/sparc/kernel/leon_pci.c +++ b/arch/sparc/kernel/leon_pci.c | |||
@@ -34,16 +34,17 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) | |||
34 | 34 | ||
35 | root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, | 35 | root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, |
36 | &resources); | 36 | &resources); |
37 | if (root_bus) { | 37 | if (!root_bus) { |
38 | /* Setup IRQs of all devices using custom routines */ | ||
39 | pci_fixup_irqs(pci_common_swizzle, info->map_irq); | ||
40 | |||
41 | /* Assign devices with resources */ | ||
42 | pci_assign_unassigned_resources(); | ||
43 | pci_bus_add_devices(root_bus); | ||
44 | } else { | ||
45 | pci_free_resource_list(&resources); | 38 | pci_free_resource_list(&resources); |
39 | return; | ||
46 | } | 40 | } |
41 | |||
42 | /* Setup IRQs of all devices using custom routines */ | ||
43 | pci_fixup_irqs(pci_common_swizzle, info->map_irq); | ||
44 | |||
45 | /* Assign devices with resources */ | ||
46 | pci_assign_unassigned_resources(); | ||
47 | pci_bus_add_devices(root_bus); | ||
47 | } | 48 | } |
48 | 49 | ||
49 | void pcibios_fixup_bus(struct pci_bus *pbus) | 50 | void pcibios_fixup_bus(struct pci_bus *pbus) |