Skip to content

Commit 5277407

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: iproc: 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 iproc 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: Scott Branden <[email protected]> Cc: Ray Jui <[email protected]> Cc: Jon Mason <[email protected]>
1 parent 90634e8 commit 5277407

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

drivers/pci/host/pcie-iproc-bcma.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
4545
struct device *dev = &bdev->dev;
4646
struct iproc_pcie *pcie;
4747
LIST_HEAD(resources);
48+
struct pci_host_bridge *bridge;
4849
int ret;
4950

50-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
51-
if (!pcie)
51+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
52+
if (!bridge)
5253
return -ENOMEM;
5354

55+
pcie = pci_host_bridge_priv(bridge);
56+
5457
pcie->dev = dev;
5558

5659
pcie->type = IPROC_PCIE_PAXB_BCMA;

drivers/pci/host/pcie-iproc-platform.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
5252
struct resource reg;
5353
resource_size_t iobase = 0;
5454
LIST_HEAD(resources);
55+
struct pci_host_bridge *bridge;
5556
int ret;
5657

57-
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
58-
if (!pcie)
58+
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
59+
if (!bridge)
5960
return -ENOMEM;
6061

62+
pcie = pci_host_bridge_priv(bridge);
63+
6164
pcie->dev = dev;
6265
pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev);
6366

drivers/pci/host/pcie-iproc.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,8 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
12591259
struct device *dev;
12601260
int ret;
12611261
void *sysdata;
1262-
struct pci_bus *bus, *child;
1262+
struct pci_bus *child;
1263+
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
12631264

12641265
dev = pcie->dev;
12651266

@@ -1306,18 +1307,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
13061307
sysdata = pcie;
13071308
#endif
13081309

1309-
bus = pci_create_root_bus(dev, 0, &iproc_pcie_ops, sysdata, res);
1310-
if (!bus) {
1311-
dev_err(dev, "unable to create PCI root bus\n");
1312-
ret = -ENOMEM;
1313-
goto err_power_off_phy;
1314-
}
1315-
pcie->root_bus = bus;
1316-
13171310
ret = iproc_pcie_check_link(pcie);
13181311
if (ret) {
13191312
dev_err(dev, "no PCIe EP device detected\n");
1320-
goto err_rm_root_bus;
1313+
goto err_power_off_phy;
13211314
}
13221315

13231316
iproc_pcie_enable(pcie);
@@ -1326,23 +1319,32 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
13261319
if (iproc_pcie_msi_enable(pcie))
13271320
dev_info(dev, "not using iProc MSI\n");
13281321

1329-
pci_scan_child_bus(bus);
1330-
pci_assign_unassigned_bus_resources(bus);
1322+
list_splice_init(res, &host->windows);
1323+
host->busnr = 0;
1324+
host->dev.parent = dev;
1325+
host->ops = &iproc_pcie_ops;
1326+
host->sysdata = sysdata;
1327+
1328+
ret = pci_scan_root_bus_bridge(host);
1329+
if (ret < 0) {
1330+
dev_err(dev, "failed to scan host: %d\n", ret);
1331+
goto err_power_off_phy;
1332+
}
13311333

13321334
if (pcie->map_irq)
13331335
pci_fixup_irqs(pci_common_swizzle, pcie->map_irq);
13341336

1335-
list_for_each_entry(child, &bus->children, node)
1337+
pci_assign_unassigned_bus_resources(host->bus);
1338+
1339+
pcie->root_bus = host->bus;
1340+
1341+
list_for_each_entry(child, &host->bus->children, node)
13361342
pcie_bus_configure_settings(child);
13371343

1338-
pci_bus_add_devices(bus);
1344+
pci_bus_add_devices(host->bus);
13391345

13401346
return 0;
13411347

1342-
err_rm_root_bus:
1343-
pci_stop_root_bus(bus);
1344-
pci_remove_root_bus(bus);
1345-
13461348
err_power_off_phy:
13471349
phy_power_off(pcie->phy);
13481350
err_exit_phy:

0 commit comments

Comments
 (0)