aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2017-06-28 16:13:58 -0400
committerBjorn Helgaas <bhelgaas@google.com>2017-07-02 17:14:25 -0400
commit9815791319a01be1ceca8b0b716219073b29a42d (patch)
tree3c838d6eabd0b86643f8e262c3c75bdf04b70424
parent4b380678f5a7d926ebe3ae163f0aff2faa925329 (diff)
PCI: altera: Convert PCI scan API to pci_scan_root_bus_bridge()
The introduction of pci_scan_root_bus_bridge() provides a PCI core API to scan a PCI root bus backed by an already initialized struct pci_host_bridge object, which simplifies the bus scan interface and makes the PCI scan root bus interface easier to generalize as members are added to the struct pci_host_bridge. Convert PCI altera host code to pci_scan_root_bus_bridge() to improve the PCI root bus scanning interface. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Ley Foon Tan <lftan@altera.com>
-rw-r--r--drivers/pci/host/pcie-altera.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index 75ec5cea26f6..7f023b286aaf 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -579,12 +579,14 @@ static int altera_pcie_probe(struct platform_device *pdev)
579 struct altera_pcie *pcie; 579 struct altera_pcie *pcie;
580 struct pci_bus *bus; 580 struct pci_bus *bus;
581 struct pci_bus *child; 581 struct pci_bus *child;
582 struct pci_host_bridge *bridge;
582 int ret; 583 int ret;
583 584
584 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 585 bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
585 if (!pcie) 586 if (!bridge)
586 return -ENOMEM; 587 return -ENOMEM;
587 588
589 pcie = pci_host_bridge_priv(bridge);
588 pcie->pdev = pdev; 590 pcie->pdev = pdev;
589 591
590 ret = altera_pcie_parse_dt(pcie); 592 ret = altera_pcie_parse_dt(pcie);
@@ -613,12 +615,20 @@ static int altera_pcie_probe(struct platform_device *pdev)
613 cra_writel(pcie, P2A_INT_ENA_ALL, P2A_INT_ENABLE); 615 cra_writel(pcie, P2A_INT_ENA_ALL, P2A_INT_ENABLE);
614 altera_pcie_host_init(pcie); 616 altera_pcie_host_init(pcie);
615 617
616 bus = pci_scan_root_bus(dev, pcie->root_bus_nr, &altera_pcie_ops, 618 list_splice_init(&pcie->resources, &bridge->windows);
617 pcie, &pcie->resources); 619 bridge->dev.parent = dev;
618 if (!bus) 620 bridge->sysdata = pcie;
619 return -ENOMEM; 621 bridge->busnr = pcie->root_bus_nr;
622 bridge->ops = &altera_pcie_ops;
623
624 ret = pci_scan_root_bus_bridge(bridge);
625 if (ret < 0)
626 return ret;
627
628 bus = bridge->bus;
620 629
621 pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); 630 pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
631
622 pci_assign_unassigned_bus_resources(bus); 632 pci_assign_unassigned_bus_resources(bus);
623 633
624 /* Configure PCI Express setting. */ 634 /* Configure PCI Express setting. */