Skip to content

Commit 6b6de6a

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: aardvark: 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 aardvark 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: Thomas Petazzoni <[email protected]>
1 parent 295aeb9 commit 6b6de6a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/pci/host/pci-aardvark.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,12 +886,14 @@ static int advk_pcie_probe(struct platform_device *pdev)
886886
struct advk_pcie *pcie;
887887
struct resource *res;
888888
struct pci_bus *bus, *child;
889+
struct pci_host_bridge *bridge;
889890
int ret, irq;
890891

891-
pcie = devm_kzalloc(dev, sizeof(struct advk_pcie), GFP_KERNEL);
892-
if (!pcie)
892+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(struct advk_pcie));
893+
if (!bridge)
893894
return -ENOMEM;
894895

896+
pcie = pci_host_bridge_priv(bridge);
895897
pcie->pdev = pdev;
896898

897899
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -929,14 +931,21 @@ static int advk_pcie_probe(struct platform_device *pdev)
929931
return ret;
930932
}
931933

932-
bus = pci_scan_root_bus(dev, 0, &advk_pcie_ops,
933-
pcie, &pcie->resources);
934-
if (!bus) {
934+
list_splice_init(&pcie->resources, &bridge->windows);
935+
bridge->dev.parent = dev;
936+
bridge->sysdata = pcie;
937+
bridge->busnr = 0;
938+
bridge->ops = &advk_pcie_ops;
939+
940+
ret = pci_scan_root_bus_bridge(bridge);
941+
if (ret < 0) {
935942
advk_pcie_remove_msi_irq_domain(pcie);
936943
advk_pcie_remove_irq_domain(pcie);
937-
return -ENOMEM;
944+
return ret;
938945
}
939946

947+
bus = bridge->bus;
948+
940949
pci_bus_assign_resources(bus);
941950

942951
list_for_each_entry(child, &bus->children, node)

0 commit comments

Comments
 (0)