Skip to content

Commit 8c790a8

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: xilinx: 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 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: Michal Simek <[email protected]>
1 parent 9815791 commit 8c790a8

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

drivers/pci/host/pcie-xilinx.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -633,16 +633,19 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
633633
struct device *dev = &pdev->dev;
634634
struct xilinx_pcie_port *port;
635635
struct pci_bus *bus, *child;
636+
struct pci_host_bridge *bridge;
636637
int err;
637638
resource_size_t iobase = 0;
638639
LIST_HEAD(res);
639640

640641
if (!dev->of_node)
641642
return -ENODEV;
642643

643-
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
644-
if (!port)
645-
return -ENOMEM;
644+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
645+
if (!bridge)
646+
return -ENODEV;
647+
648+
port = pci_host_bridge_priv(bridge);
646649

647650
port->dev = dev;
648651

@@ -671,17 +674,23 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
671674
if (err)
672675
goto error;
673676

674-
bus = pci_create_root_bus(dev, 0, &xilinx_pcie_ops, port, &res);
675-
if (!bus) {
676-
err = -ENOMEM;
677-
goto error;
678-
}
677+
678+
list_splice_init(&res, &bridge->windows);
679+
bridge->dev.parent = dev;
680+
bridge->sysdata = port;
681+
bridge->busnr = 0;
682+
bridge->ops = &xilinx_pcie_ops;
679683

680684
#ifdef CONFIG_PCI_MSI
681685
xilinx_pcie_msi_chip.dev = dev;
682-
bus->msi = &xilinx_pcie_msi_chip;
686+
bridge->msi = &xilinx_pcie_msi_chip;
683687
#endif
684-
pci_scan_child_bus(bus);
688+
err = pci_scan_root_bus_bridge(bridge);
689+
if (err < 0)
690+
goto error;
691+
692+
bus = bridge->bus;
693+
685694
pci_assign_unassigned_bus_resources(bus);
686695
#ifndef CONFIG_MICROBLAZE
687696
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);

0 commit comments

Comments
 (0)