PCI: Simplify __pci_assign_resource() coding style
authorBjorn Helgaas <bhelgaas@google.com>
Tue, 20 May 2014 00:39:07 +0000 (18:39 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 23 May 2014 18:40:49 +0000 (12:40 -0600)
If an allocation succeeds, we can return success immediately.  Then we
don't have to test for success in the subsequent code.

No functional change.

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

index 2473f091a9cc5e0270866c7df0411c3a3f8b907d..3bdac9dc4a880555145d43d1ceff510b8117ae12 100644 (file)
@@ -213,9 +213,10 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
        ret = pci_bus_alloc_resource(bus, res, size, align, min,
                                     IORESOURCE_PREFETCH | IORESOURCE_MEM_64,
                                     pcibios_align_resource, dev);
+       if (ret == 0)
+               return 0;
 
-       if (ret < 0 &&
-           (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) ==
+       if ((res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) ==
             (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) {
                /*
                 * That failed.
@@ -225,10 +226,11 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
                ret = pci_bus_alloc_resource(bus, res, size, align, min,
                                             IORESOURCE_PREFETCH,
                                             pcibios_align_resource, dev);
+               if (ret == 0)
+                       return 0;
        }
 
-       if (ret < 0 &&
-           (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))) {
+       if (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) {
                /*
                 * That failed.
                 *