Skip to content

Commit 123db53

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: xilinx-nwl: 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 xilinx-nwl 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: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
1 parent ae13cb9 commit 123db53

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

drivers/pci/host/pcie-xilinx-nwl.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,16 @@ static int nwl_pcie_probe(struct platform_device *pdev)
791791
struct nwl_pcie *pcie;
792792
struct pci_bus *bus;
793793
struct pci_bus *child;
794+
struct pci_host_bridge *bridge;
794795
int err;
795796
resource_size_t iobase = 0;
796797
LIST_HEAD(res);
797798

798-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
799-
if (!pcie)
800-
return -ENOMEM;
799+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
800+
if (!bridge)
801+
return -ENODEV;
802+
803+
pcie = pci_host_bridge_priv(bridge);
801804

802805
pcie->dev = dev;
803806
pcie->ecam_value = NWL_ECAM_VALUE_DEFAULT;
@@ -830,12 +833,11 @@ static int nwl_pcie_probe(struct platform_device *pdev)
830833
goto error;
831834
}
832835

833-
bus = pci_create_root_bus(dev, pcie->root_busno,
834-
&nwl_pcie_ops, pcie, &res);
835-
if (!bus) {
836-
err = -ENOMEM;
837-
goto error;
838-
}
836+
list_splice_init(&res, &bridge->windows);
837+
bridge->dev.parent = dev;
838+
bridge->sysdata = pcie;
839+
bridge->busnr = pcie->root_busno;
840+
bridge->ops = &nwl_pcie_ops;
839841

840842
if (IS_ENABLED(CONFIG_PCI_MSI)) {
841843
err = nwl_pcie_enable_msi(pcie);
@@ -844,7 +846,13 @@ static int nwl_pcie_probe(struct platform_device *pdev)
844846
goto error;
845847
}
846848
}
847-
pci_scan_child_bus(bus);
849+
850+
err = pci_scan_root_bus_bridge(bridge);
851+
if (err)
852+
goto error;
853+
854+
bus = bridge->bus;
855+
848856
pci_assign_unassigned_bus_resources(bus);
849857
list_for_each_entry(child, &bus->children, node)
850858
pcie_bus_configure_settings(child);

0 commit comments

Comments
 (0)