PCI: Return early on allocation failures to unindent mainline code
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 5 Jun 2013 20:22:11 +0000 (14:22 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 14 Jun 2013 23:39:45 +0000 (17:39 -0600)
On allocation failure, return early so the main body of the function
doesn't have to be indented as the body of an "if" statement.  No
functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/probe.c

index a723b2b93ab4bbe1b69ade468c3a1d4566faed33..14af6ef4959c3de6d0446a6257359cae7cf402d5 100644 (file)
@@ -451,20 +451,21 @@ void pci_read_bridge_bases(struct pci_bus *child)
        }
 }
 
-static struct pci_bus * pci_alloc_bus(void)
+static struct pci_bus *pci_alloc_bus(void)
 {
        struct pci_bus *b;
 
        b = kzalloc(sizeof(*b), GFP_KERNEL);
-       if (b) {
-               INIT_LIST_HEAD(&b->node);
-               INIT_LIST_HEAD(&b->children);
-               INIT_LIST_HEAD(&b->devices);
-               INIT_LIST_HEAD(&b->slots);
-               INIT_LIST_HEAD(&b->resources);
-               b->max_bus_speed = PCI_SPEED_UNKNOWN;
-               b->cur_bus_speed = PCI_SPEED_UNKNOWN;
-       }
+       if (!b)
+               return NULL;
+
+       INIT_LIST_HEAD(&b->node);
+       INIT_LIST_HEAD(&b->children);
+       INIT_LIST_HEAD(&b->devices);
+       INIT_LIST_HEAD(&b->slots);
+       INIT_LIST_HEAD(&b->resources);
+       b->max_bus_speed = PCI_SPEED_UNKNOWN;
+       b->cur_bus_speed = PCI_SPEED_UNKNOWN;
        return b;
 }
 
@@ -485,11 +486,11 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
        struct pci_host_bridge *bridge;
 
        bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
-       if (bridge) {
-               INIT_LIST_HEAD(&bridge->windows);
-               bridge->bus = b;
-       }
+       if (!bridge)
+               return NULL;
 
+       INIT_LIST_HEAD(&bridge->windows);
+       bridge->bus = b;
        return bridge;
 }