Skip to content

Commit 90634e8

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: rcar: 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 rcar 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: Simon Horman <[email protected]>
1 parent 6b6de6a commit 90634e8

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

drivers/pci/host/pcie-rcar.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,28 +450,32 @@ static void rcar_pcie_force_speedup(struct rcar_pcie *pcie)
450450
static int rcar_pcie_enable(struct rcar_pcie *pcie)
451451
{
452452
struct device *dev = pcie->dev;
453+
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
453454
struct pci_bus *bus, *child;
454-
LIST_HEAD(res);
455+
int ret;
455456

456457
/* Try setting 5 GT/s link speed */
457458
rcar_pcie_force_speedup(pcie);
458459

459-
rcar_pcie_setup(&res, pcie);
460+
rcar_pcie_setup(&bridge->windows, pcie);
460461

461462
pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS);
462463

464+
bridge->dev.parent = dev;
465+
bridge->sysdata = pcie;
466+
bridge->busnr = pcie->root_bus_nr;
467+
bridge->ops = &rcar_pcie_ops;
463468
if (IS_ENABLED(CONFIG_PCI_MSI))
464-
bus = pci_scan_root_bus_msi(dev, pcie->root_bus_nr,
465-
&rcar_pcie_ops, pcie, &res, &pcie->msi.chip);
466-
else
467-
bus = pci_scan_root_bus(dev, pcie->root_bus_nr,
468-
&rcar_pcie_ops, pcie, &res);
469+
bridge->msi = &pcie->msi.chip;
469470

470-
if (!bus) {
471-
dev_err(dev, "Scanning rootbus failed");
472-
return -ENODEV;
471+
ret = pci_scan_root_bus_bridge(bridge);
472+
if (ret < 0) {
473+
kfree(bridge);
474+
return ret;
473475
}
474476

477+
bus = bridge->bus;
478+
475479
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
476480

477481
pci_bus_size_bridges(bus);
@@ -1127,11 +1131,14 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11271131
unsigned int data;
11281132
int err;
11291133
int (*hw_init_fn)(struct rcar_pcie *);
1134+
struct pci_host_bridge *bridge;
11301135

1131-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
1132-
if (!pcie)
1136+
bridge = pci_alloc_host_bridge(sizeof(*pcie));
1137+
if (!bridge)
11331138
return -ENOMEM;
11341139

1140+
pcie = pci_host_bridge_priv(bridge);
1141+
11351142
pcie->dev = dev;
11361143

11371144
INIT_LIST_HEAD(&pcie->resources);
@@ -1141,12 +1148,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11411148
err = rcar_pcie_get_resources(pcie);
11421149
if (err < 0) {
11431150
dev_err(dev, "failed to request resources: %d\n", err);
1144-
return err;
1151+
goto err_free_bridge;
11451152
}
11461153

11471154
err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node);
11481155
if (err)
1149-
return err;
1156+
goto err_free_bridge;
11501157

11511158
pm_runtime_enable(dev);
11521159
err = pm_runtime_get_sync(dev);
@@ -1183,6 +1190,9 @@ static int rcar_pcie_probe(struct platform_device *pdev)
11831190

11841191
return 0;
11851192

1193+
err_free_bridge:
1194+
pci_free_host_bridge(bridge);
1195+
11861196
err_pm_put:
11871197
pm_runtime_put(dev);
11881198

0 commit comments

Comments
 (0)