PCI: cadence: Use struct pci_host_bridge.windows list directly
authorRob Herring <robh@kernel.org>
Fri, 22 May 2020 23:48:18 +0000 (17:48 -0600)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 6 Jul 2020 08:52:42 +0000 (09:52 +0100)
There's no need to create a temporary resource list and then splice it to
struct pci_host_bridge.windows list. Just use pci_host_bridge.windows
directly. The necessary clean-up is already handled by the PCI core.

Link: https://lore.kernel.org/r/20200522234832.954484-2-robh@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tom Joseph <tjoseph@cadence.com>
drivers/pci/controller/cadence/pcie-cadence-host.c

index 8c2543f..9f77e47 100644 (file)
@@ -169,14 +169,15 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)
 }
 
 static int cdns_pcie_host_init(struct device *dev,
-                              struct list_head *resources,
                               struct cdns_pcie_rc *rc)
 {
+       struct pci_host_bridge *bridge = pci_host_bridge_from_priv(rc);
        struct resource *bus_range = NULL;
        int err;
 
        /* Parse our PCI ranges and request their resources */
-       err = pci_parse_request_of_pci_ranges(dev, resources, NULL, &bus_range);
+       err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL,
+                                             &bus_range);
        if (err)
                return err;
 
@@ -185,17 +186,9 @@ static int cdns_pcie_host_init(struct device *dev,
 
        err = cdns_pcie_host_init_root_port(rc);
        if (err)
-               goto err_out;
-
-       err = cdns_pcie_host_init_address_translation(rc);
-       if (err)
-               goto err_out;
-
-       return 0;
+               return err;
 
- err_out:
-       pci_free_resource_list(resources);
-       return err;
+       return cdns_pcie_host_init_address_translation(rc);
 }
 
 int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
@@ -204,7 +197,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
        struct platform_device *pdev = to_platform_device(dev);
        struct device_node *np = dev->of_node;
        struct pci_host_bridge *bridge;
-       struct list_head resources;
        struct cdns_pcie *pcie;
        struct resource *res;
        int ret;
@@ -248,11 +240,10 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
 
        pcie->mem_res = res;
 
-       ret = cdns_pcie_host_init(dev, &resources, rc);
+       ret = cdns_pcie_host_init(dev, rc);
        if (ret)
                goto err_init;
 
-       list_splice_init(&resources, &bridge->windows);
        bridge->dev.parent = dev;
        bridge->busnr = pcie->bus;
        bridge->ops = &cdns_pcie_host_ops;
@@ -261,13 +252,10 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
 
        ret = pci_host_probe(bridge);
        if (ret < 0)
-               goto err_host_probe;
+               goto err_init;
 
        return 0;
 
- err_host_probe:
-       pci_free_resource_list(&resources);
-
  err_init:
        pm_runtime_put_sync(dev);