PCI: Cleanup control flow
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 12 Mar 2015 20:07:04 +0000 (15:07 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 19 Mar 2015 15:17:22 +0000 (10:17 -0500)
Return errors immediately so the straightline path is the normal,
no-error path.  No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/arm/mach-dove/pcie.c
arch/arm/mach-mv78xx0/pcie.c
arch/arm/mach-orion5x/pci.c
arch/mips/pci/pci.c
arch/sh/drivers/pci/pci.c
arch/sparc/kernel/leon_pci.c

index 8a275f2975220f94063442c569510dbe5ea72dc9..91fe9714457004008d4701218deeb1c4cae1bbdf 100644 (file)
@@ -155,17 +155,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup);
 static struct pci_bus __init *
 dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 {
-       struct pci_bus *bus;
-
-       if (nr < num_pcie_ports) {
-               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
-                                       &sys->resources);
-       } else {
-               bus = NULL;
+       if (nr >= num_pcie_ports) {
                BUG();
+               return NULL;
        }
 
-       return bus;
+       return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                &sys->resources);
 }
 
 static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
index 445e553f4a28e886469e4cd112ededdde1057ccb..097ea4cb1136f53bc9cf4f7b8857fa816bf3e6be 100644 (file)
@@ -197,17 +197,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup);
 static struct pci_bus __init *
 mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 {
-       struct pci_bus *bus;
-
-       if (nr < num_pcie_ports) {
-               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
-                                       &sys->resources);
-       } else {
-               bus = NULL;
+       if (nr >= num_pcie_ports) {
                BUG();
+               return NULL;
        }
 
-       return bus;
+       return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                &sys->resources);
 }
 
 static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot,
index 87a12d6930ffc4525a1a1335789162711968e4fe..b02f3947be516192adb7240ce83fc4eb89318fc2 100644 (file)
@@ -540,37 +540,33 @@ void __init orion5x_pci_set_cardbus_mode(void)
 
 int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys)
 {
-       int ret = 0;
-
        vga_base = ORION5X_PCIE_MEM_PHYS_BASE;
 
        if (nr == 0) {
                orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr);
-               ret = pcie_setup(sys);
-       } else if (nr == 1 && !orion5x_pci_disabled) {
+               return pcie_setup(sys);
+       }
+
+       if (nr == 1 && !orion5x_pci_disabled) {
                orion5x_pci_set_bus_nr(sys->busnr);
-               ret = pci_setup(sys);
+               return pci_setup(sys);
        }
 
-       return ret;
+       return 0;
 }
 
 struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys)
 {
-       struct pci_bus *bus;
+       if (nr == 0)
+               return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                        &sys->resources);
 
-       if (nr == 0) {
-               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
-                                       &sys->resources);
-       } else if (nr == 1 && !orion5x_pci_disabled) {
-               bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
-                                       &sys->resources);
-       } else {
-               bus = NULL;
-               BUG();
-       }
+       if (nr == 1 && !orion5x_pci_disabled)
+               return pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
+                                        &sys->resources);
 
-       return bus;
+       BUG();
+       return NULL;
 }
 
 int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
index 9eb54b557c9f9219752e2d066791f150b7b0ee72..8bb13a4af68a097057f55d9379961a6f0319a4e4 100644 (file)
@@ -94,28 +94,29 @@ static void pcibios_scanbus(struct pci_controller *hose)
        pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
        bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
                                &resources);
-       if (!bus)
-               pci_free_resource_list(&resources);
-
        hose->bus = bus;
 
        need_domain_info = need_domain_info || hose->index;
        hose->need_domain_info = need_domain_info;
-       if (bus) {
-               next_busno = bus->busn_res.end + 1;
-               /* Don't allow 8-bit bus number overflow inside the hose -
-                  reserve some space for bridges. */
-               if (next_busno > 224) {
-                       next_busno = 0;
-                       need_domain_info = 1;
-               }
 
-               if (!pci_has_flag(PCI_PROBE_ONLY)) {
-                       pci_bus_size_bridges(bus);
-                       pci_bus_assign_resources(bus);
-               }
-               pci_bus_add_devices(bus);
+       if (!bus) {
+               pci_free_resource_list(&resources);
+               return;
+       }
+
+       next_busno = bus->busn_res.end + 1;
+       /* Don't allow 8-bit bus number overflow inside the hose -
+          reserve some space for bridges. */
+       if (next_busno > 224) {
+               next_busno = 0;
+               need_domain_info = 1;
+       }
+
+       if (!pci_has_flag(PCI_PROBE_ONLY)) {
+               pci_bus_size_bridges(bus);
+               pci_bus_assign_resources(bus);
        }
+       pci_bus_add_devices(bus);
 }
 
 #ifdef CONFIG_OF
index efc10519916ab684a14bbc5ec8237618d50133e9..d5462b7bc5148893f4348aa5805fd74a3a861ed2 100644 (file)
@@ -58,21 +58,23 @@ static void pcibios_scanbus(struct pci_channel *hose)
 
        need_domain_info = need_domain_info || hose->index;
        hose->need_domain_info = need_domain_info;
-       if (bus) {
-               next_busno = bus->busn_res.end + 1;
-               /* Don't allow 8-bit bus number overflow inside the hose -
-                  reserve some space for bridges. */
-               if (next_busno > 224) {
-                       next_busno = 0;
-                       need_domain_info = 1;
-               }
 
-               pci_bus_size_bridges(bus);
-               pci_bus_assign_resources(bus);
-               pci_bus_add_devices(bus);
-       } else {
+       if (!bus) {
                pci_free_resource_list(&resources);
+               return;
+       }
+
+       next_busno = bus->busn_res.end + 1;
+       /* Don't allow 8-bit bus number overflow inside the hose -
+          reserve some space for bridges. */
+       if (next_busno > 224) {
+               next_busno = 0;
+               need_domain_info = 1;
        }
+
+       pci_bus_size_bridges(bus);
+       pci_bus_assign_resources(bus);
+       pci_bus_add_devices(bus);
 }
 
 /*
index 297107679fdfc397268498907e76cb3edb65a265..4371f72ff02500d57c56343a254468375324490c 100644 (file)
@@ -34,16 +34,17 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 
        root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
                                     &resources);
-       if (root_bus) {
-               /* Setup IRQs of all devices using custom routines */
-               pci_fixup_irqs(pci_common_swizzle, info->map_irq);
-
-               /* Assign devices with resources */
-               pci_assign_unassigned_resources();
-               pci_bus_add_devices(root_bus);
-       } else {
+       if (!root_bus) {
                pci_free_resource_list(&resources);
+               return;
        }
+
+       /* Setup IRQs of all devices using custom routines */
+       pci_fixup_irqs(pci_common_swizzle, info->map_irq);
+
+       /* Assign devices with resources */
+       pci_assign_unassigned_resources();
+       pci_bus_add_devices(root_bus);
 }
 
 void pcibios_fixup_bus(struct pci_bus *pbus)