Skip to content

Commit 4b38067

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: versatile: 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 versatile host code to pci_scan_root_bus_bridge() to improve the PCI root bus scanning interface. Signed-off-by: Lorenzo Pieralisi <[email protected]> [bhelgaas: folded in fix from Arnd Bergmann <[email protected]>: http://lkml.kernel.org/r/[email protected]] Signed-off-by: Bjorn Helgaas <[email protected]> Cc: Rob Herring <[email protected]>
1 parent 5277407 commit 4b38067

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

drivers/pci/host/pci-versatile.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ static int versatile_pci_probe(struct platform_device *pdev)
125125
u32 val;
126126
void __iomem *local_pci_cfg_base;
127127
struct pci_bus *bus, *child;
128+
struct pci_host_bridge *bridge;
128129
LIST_HEAD(pci_res);
129130

131+
bridge = devm_pci_alloc_host_bridge(&pdev->dev, 0);
132+
if (!bridge)
133+
return -ENOMEM;
134+
130135
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131136
versatile_pci_base = devm_ioremap_resource(&pdev->dev, res);
132137
if (IS_ERR(versatile_pci_base))
@@ -199,11 +204,20 @@ static int versatile_pci_probe(struct platform_device *pdev)
199204
pci_add_flags(PCI_ENABLE_PROC_DOMAINS);
200205
pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC);
201206

202-
bus = pci_scan_root_bus(&pdev->dev, 0, &pci_versatile_ops, NULL, &pci_res);
203-
if (!bus)
204-
return -ENOMEM;
207+
list_splice_init(&pci_res, &bridge->windows);
208+
bridge->dev.parent = &pdev->dev;
209+
bridge->sysdata = NULL;
210+
bridge->busnr = 0;
211+
bridge->ops = &pci_versatile_ops;
212+
213+
ret = pci_scan_root_bus_bridge(bridge);
214+
if (ret < 0)
215+
return ret;
216+
217+
bus = bridge->bus;
205218

206219
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
220+
207221
pci_assign_unassigned_bus_resources(bus);
208222
list_for_each_entry(child, &bus->children, node)
209223
pcie_bus_configure_settings(child);

0 commit comments

Comments
 (0)