PCI: aardvark: Use pci_parse_request_of_pci_ranges()
Convert aardvark to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Andrew Murray <andrew.murray@arm.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
65991f4376
commit
4e5be6f81b
|
@ -186,7 +186,6 @@
|
||||||
struct advk_pcie {
|
struct advk_pcie {
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
struct list_head resources;
|
|
||||||
struct irq_domain *irq_domain;
|
struct irq_domain *irq_domain;
|
||||||
struct irq_chip irq_chip;
|
struct irq_chip irq_chip;
|
||||||
struct irq_domain *msi_domain;
|
struct irq_domain *msi_domain;
|
||||||
|
@ -910,63 +909,11 @@ static irqreturn_t advk_pcie_irq_handler(int irq, void *arg)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
|
|
||||||
{
|
|
||||||
int err, res_valid = 0;
|
|
||||||
struct device *dev = &pcie->pdev->dev;
|
|
||||||
struct resource_entry *win, *tmp;
|
|
||||||
resource_size_t iobase;
|
|
||||||
|
|
||||||
INIT_LIST_HEAD(&pcie->resources);
|
|
||||||
|
|
||||||
err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
|
|
||||||
&pcie->resources, &iobase);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
err = devm_request_pci_bus_resources(dev, &pcie->resources);
|
|
||||||
if (err)
|
|
||||||
goto out_release_res;
|
|
||||||
|
|
||||||
resource_list_for_each_entry_safe(win, tmp, &pcie->resources) {
|
|
||||||
struct resource *res = win->res;
|
|
||||||
|
|
||||||
switch (resource_type(res)) {
|
|
||||||
case IORESOURCE_IO:
|
|
||||||
err = devm_pci_remap_iospace(dev, res, iobase);
|
|
||||||
if (err) {
|
|
||||||
dev_warn(dev, "error %d: failed to map resource %pR\n",
|
|
||||||
err, res);
|
|
||||||
resource_list_destroy_entry(win);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IORESOURCE_MEM:
|
|
||||||
res_valid |= !(res->flags & IORESOURCE_PREFETCH);
|
|
||||||
break;
|
|
||||||
case IORESOURCE_BUS:
|
|
||||||
pcie->root_bus_nr = res->start;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!res_valid) {
|
|
||||||
dev_err(dev, "non-prefetchable memory resource required\n");
|
|
||||||
err = -EINVAL;
|
|
||||||
goto out_release_res;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
out_release_res:
|
|
||||||
pci_free_resource_list(&pcie->resources);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int advk_pcie_probe(struct platform_device *pdev)
|
static int advk_pcie_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct advk_pcie *pcie;
|
struct advk_pcie *pcie;
|
||||||
struct resource *res;
|
struct resource *res, *bus;
|
||||||
struct pci_host_bridge *bridge;
|
struct pci_host_bridge *bridge;
|
||||||
int ret, irq;
|
int ret, irq;
|
||||||
|
|
||||||
|
@ -991,11 +938,13 @@ static int advk_pcie_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = advk_pcie_parse_request_of_pci_ranges(pcie);
|
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
|
||||||
|
&bus);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to parse resources\n");
|
dev_err(dev, "Failed to parse resources\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
pcie->root_bus_nr = bus->start;
|
||||||
|
|
||||||
advk_pcie_setup_hw(pcie);
|
advk_pcie_setup_hw(pcie);
|
||||||
|
|
||||||
|
@ -1014,7 +963,6 @@ static int advk_pcie_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_splice_init(&pcie->resources, &bridge->windows);
|
|
||||||
bridge->dev.parent = dev;
|
bridge->dev.parent = dev;
|
||||||
bridge->sysdata = pcie;
|
bridge->sysdata = pcie;
|
||||||
bridge->busnr = 0;
|
bridge->busnr = 0;
|
||||||
|
|
Loading…
Reference in New Issue