diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2014-07-04 15:58:15 -0600 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-07-08 16:29:08 -0600 |
commit | 28f6dbe2c669c6a02c04c8ece21cafbcb20370ab (patch) | |
tree | eaf95abc97f3ca393daea296d5f8b282077a8391 /drivers/pci/setup-res.c | |
parent | 096d4221f92fb205ade35f35e3ceeba5662528fe (diff) | |
download | linux-28f6dbe2c669c6a02c04c8ece21cafbcb20370ab.tar.bz2 |
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>
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r-- | drivers/pci/setup-res.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 481c4e18693a..532dc540dc5d 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -305,14 +305,16 @@ int pci_assign_resource(struct pci_dev *dev, int resno) if (ret < 0) ret = pci_revert_fw_address(res, dev, resno, size); - if (!ret) { - res->flags &= ~IORESOURCE_UNSET; - res->flags &= ~IORESOURCE_STARTALIGN; - dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) - pci_update_resource(dev, resno); - } - return ret; + if (ret) + return ret; + + res->flags &= ~IORESOURCE_UNSET; + res->flags &= ~IORESOURCE_STARTALIGN; + dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); + if (resno < PCI_BRIDGE_RESOURCES) + pci_update_resource(dev, resno); + + return 0; } EXPORT_SYMBOL(pci_assign_resource); @@ -335,19 +337,20 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz /* already aligned with min_align */ new_size = resource_size(res) + addsize; ret = _pci_assign_resource(dev, resno, new_size, min_align); - if (!ret) { - res->flags &= ~IORESOURCE_UNSET; - res->flags &= ~IORESOURCE_STARTALIGN; - dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) - pci_update_resource(dev, resno); - } else { + if (ret) { res->flags = flags; dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n", resno, res, (unsigned long long) addsize); + return ret; } - return ret; + res->flags &= ~IORESOURCE_UNSET; + res->flags &= ~IORESOURCE_STARTALIGN; + dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); + if (resno < PCI_BRIDGE_RESOURCES) + pci_update_resource(dev, resno); + + return 0; } int pci_enable_resources(struct pci_dev *dev, int mask) |