Skip to content

Commit

Permalink
PCI: altera: Use pci_parse_request_of_pci_ranges()
Browse files Browse the repository at this point in the history
Convert altera host bridge 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.

If an I/O range is present, then it will now be mapped. It's expected
that h/w which doesn't support I/O range will not define one.

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: Ley Foon Tan <lftan@altera.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: rfi@lists.rocketboards.org
  • Loading branch information
Rob Herring authored and Lorenzo Pieralisi committed Oct 29, 2019
1 parent 4e5be6f commit e634e3e
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions drivers/pci/controller/pcie-altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct altera_pcie {
u8 root_bus_nr;
struct irq_domain *irq_domain;
struct resource bus_range;
struct list_head resources;
const struct altera_pcie_data *pcie_data;
};

Expand Down Expand Up @@ -670,39 +669,6 @@ static void altera_pcie_isr(struct irq_desc *desc)
chained_irq_exit(chip, desc);
}

static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie)
{
int err, res_valid = 0;
struct device *dev = &pcie->pdev->dev;
struct resource_entry *win;

err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
&pcie->resources, NULL);
if (err)
return err;

err = devm_request_pci_bus_resources(dev, &pcie->resources);
if (err)
goto out_release_res;

resource_list_for_each_entry(win, &pcie->resources) {
struct resource *res = win->res;

if (resource_type(res) == IORESOURCE_MEM)
res_valid |= !(res->flags & IORESOURCE_PREFETCH);
}

if (res_valid)
return 0;

dev_err(dev, "non-prefetchable memory resource required\n");
err = -EINVAL;

out_release_res:
pci_free_resource_list(&pcie->resources);
return err;
}

static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
{
struct device *dev = &pcie->pdev->dev;
Expand Down Expand Up @@ -833,9 +799,8 @@ static int altera_pcie_probe(struct platform_device *pdev)
return ret;
}

INIT_LIST_HEAD(&pcie->resources);

ret = altera_pcie_parse_request_of_pci_ranges(pcie);
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
NULL);
if (ret) {
dev_err(dev, "Failed add resources\n");
return ret;
Expand All @@ -853,7 +818,6 @@ static int altera_pcie_probe(struct platform_device *pdev)
cra_writel(pcie, P2A_INT_ENA_ALL, P2A_INT_ENABLE);
altera_pcie_host_init(pcie);

list_splice_init(&pcie->resources, &bridge->windows);
bridge->dev.parent = dev;
bridge->sysdata = pcie;
bridge->busnr = pcie->root_bus_nr;
Expand Down Expand Up @@ -884,7 +848,6 @@ static int altera_pcie_remove(struct platform_device *pdev)

pci_stop_root_bus(bridge->bus);
pci_remove_root_bus(bridge->bus);
pci_free_resource_list(&pcie->resources);
altera_pcie_irq_teardown(pcie);

return 0;
Expand Down

0 comments on commit e634e3e

Please sign in to comment.