Skip to content

Commit 9af275b

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: xgene: 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 xgene host code to pci_scan_root_bus_bridge() to improve the PCI root bus scanning interface. Tested-by: Khuong Dinh <[email protected]> # with e1000e Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: Tanmay Inamdar <[email protected]>
1 parent 8c790a8 commit 9af275b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/pci/host/pci-xgene.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,13 +636,16 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
636636
struct xgene_pcie_port *port;
637637
resource_size_t iobase = 0;
638638
struct pci_bus *bus, *child;
639+
struct pci_host_bridge *bridge;
639640
int ret;
640641
LIST_HEAD(res);
641642

642-
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
643-
if (!port)
643+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
644+
if (!bridge)
644645
return -ENOMEM;
645646

647+
port = pci_host_bridge_priv(bridge);
648+
646649
port->node = of_node_get(dn);
647650
port->dev = dev;
648651

@@ -670,11 +673,17 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
670673
if (ret)
671674
goto error;
672675

673-
bus = pci_create_root_bus(dev, 0, &xgene_pcie_ops, port, &res);
674-
if (!bus) {
675-
ret = -ENOMEM;
676+
list_splice_init(&res, &bridge->windows);
677+
bridge->dev.parent = dev;
678+
bridge->sysdata = port;
679+
bridge->busnr = 0;
680+
bridge->ops = &xgene_pcie_ops;
681+
682+
ret = pci_scan_root_bus_bridge(bridge);
683+
if (ret < 0)
676684
goto error;
677-
}
685+
686+
bus = bridge->bus;
678687

679688
pci_scan_child_bus(bus);
680689
pci_assign_unassigned_bus_resources(bus);

0 commit comments

Comments
 (0)