Skip to content

Commit ae13cb9

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: rockchip: 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 rockchip 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: Wenrui Li <wenrui.li@rock-chips.com> Cc: Shawn Lin <shawn.lin@rock-chips.com>
1 parent 4246a86 commit ae13cb9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/pci/host/pcie-rockchip.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
12841284
struct rockchip_pcie *rockchip;
12851285
struct device *dev = &pdev->dev;
12861286
struct pci_bus *bus, *child;
1287+
struct pci_host_bridge *bridge;
12871288
struct resource_entry *win;
12881289
resource_size_t io_base;
12891290
struct resource *mem;
@@ -1295,10 +1296,12 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
12951296
if (!dev->of_node)
12961297
return -ENODEV;
12971298

1298-
rockchip = devm_kzalloc(dev, sizeof(*rockchip), GFP_KERNEL);
1299-
if (!rockchip)
1299+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rockchip));
1300+
if (!bridge)
13001301
return -ENOMEM;
13011302

1303+
rockchip = pci_host_bridge_priv(bridge);
1304+
13021305
platform_set_drvdata(pdev, rockchip);
13031306
rockchip->dev = dev;
13041307

@@ -1396,11 +1399,18 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
13961399
goto err_free_res;
13971400
}
13981401

1399-
bus = pci_scan_root_bus(&pdev->dev, 0, &rockchip_pcie_ops, rockchip, &res);
1400-
if (!bus) {
1401-
err = -ENOMEM;
1402+
list_splice_init(&res, &bridge->windows);
1403+
bridge->dev.parent = &pdev->dev;
1404+
bridge->sysdata = rockchip;
1405+
bridge->busnr = 0;
1406+
bridge->ops = &rockchip_pcie_ops;
1407+
1408+
err = pci_scan_root_bus_bridge(bridge);
1409+
if (!err)
14021410
goto err_free_res;
1403-
}
1411+
1412+
bus = bridge->bus;
1413+
14041414
rockchip->root_bus = bus;
14051415

14061416
pci_bus_size_bridges(bus);

0 commit comments

Comments
 (0)