Skip to content

Commit 9815791

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
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 <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: Ley Foon Tan <[email protected]>
1 parent 4b38067 commit 9815791

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/pci/host/pcie-altera.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,14 @@ static int altera_pcie_probe(struct platform_device *pdev)
579579
struct altera_pcie *pcie;
580580
struct pci_bus *bus;
581581
struct pci_bus *child;
582+
struct pci_host_bridge *bridge;
582583
int ret;
583584

584-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
585-
if (!pcie)
585+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
586+
if (!bridge)
586587
return -ENOMEM;
587588

589+
pcie = pci_host_bridge_priv(bridge);
588590
pcie->pdev = pdev;
589591

590592
ret = altera_pcie_parse_dt(pcie);
@@ -613,12 +615,20 @@ static int altera_pcie_probe(struct platform_device *pdev)
613615
cra_writel(pcie, P2A_INT_ENA_ALL, P2A_INT_ENABLE);
614616
altera_pcie_host_init(pcie);
615617

616-
bus = pci_scan_root_bus(dev, pcie->root_bus_nr, &altera_pcie_ops,
617-
pcie, &pcie->resources);
618-
if (!bus)
619-
return -ENOMEM;
618+
list_splice_init(&pcie->resources, &bridge->windows);
619+
bridge->dev.parent = dev;
620+
bridge->sysdata = pcie;
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;
620629

621630
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
631+
622632
pci_assign_unassigned_bus_resources(bus);
623633

624634
/* Configure PCI Express setting. */

0 commit comments

Comments
 (0)