Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+63 -71
+4 -8
arch/arm/mach-dove/pcie.c
··· 155 155 static struct pci_bus __init * 156 156 dove_pcie_scan_bus(int nr, struct pci_sys_data *sys) 157 157 { 158 - struct pci_bus *bus; 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; 158 + if (nr >= num_pcie_ports) { 165 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 167 static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+4 -8
arch/arm/mach-mv78xx0/pcie.c
··· 197 197 static struct pci_bus __init * 198 198 mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys) 199 199 { 200 - struct pci_bus *bus; 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; 200 + if (nr >= num_pcie_ports) { 207 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 209 static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot,
+15 -19
arch/arm/mach-orion5x/pci.c
··· 540 540 541 541 int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys) 542 542 { 543 - int ret = 0; 544 - 545 543 vga_base = ORION5X_PCIE_MEM_PHYS_BASE; 546 544 547 545 if (nr == 0) { 548 546 orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr); 549 - ret = pcie_setup(sys); 550 - } else if (nr == 1 && !orion5x_pci_disabled) { 551 - orion5x_pci_set_bus_nr(sys->busnr); 552 - ret = pci_setup(sys); 547 + return pcie_setup(sys); 553 548 } 554 549 555 - return ret; 550 + if (nr == 1 && !orion5x_pci_disabled) { 551 + orion5x_pci_set_bus_nr(sys->busnr); 552 + return pci_setup(sys); 553 + } 554 + 555 + return 0; 556 556 } 557 557 558 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) { 563 - bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, 564 - &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 - } 564 + if (nr == 1 && !orion5x_pci_disabled) 565 + return pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys, 566 + &sys->resources); 572 567 573 - return bus; 568 + BUG(); 569 + return NULL; 574 570 } 575 571 576 572 int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+17 -16
arch/mips/pci/pci.c
··· 94 94 pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); 95 95 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 96 96 &resources); 97 - if (!bus) 98 - pci_free_resource_list(&resources); 99 - 100 97 hose->bus = bus; 101 98 102 99 need_domain_info = need_domain_info || hose->index; 103 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)) { 114 - pci_bus_size_bridges(bus); 115 - pci_bus_assign_resources(bus); 116 - } 117 - pci_bus_add_devices(bus); 102 + if (!bus) { 103 + pci_free_resource_list(&resources); 104 + return; 118 105 } 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 + } 119 + pci_bus_add_devices(bus); 119 120 } 120 121 121 122 #ifdef CONFIG_OF
+14 -12
arch/sh/drivers/pci/pci.c
··· 58 58 59 59 need_domain_info = need_domain_info || hose->index; 60 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); 71 - pci_bus_assign_resources(bus); 72 - pci_bus_add_devices(bus); 73 - } else { 62 + if (!bus) { 74 63 pci_free_resource_list(&resources); 64 + return; 75 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; 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 /*
+9 -8
arch/sparc/kernel/leon_pci.c
··· 34 34 35 35 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, 36 36 &resources); 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 { 37 + if (!root_bus) { 45 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 50 void pcibios_fixup_bus(struct pci_bus *pbus)