Skip to content

Commit 4246a86

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: generic: 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 host-common 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> Acked-by: Will Deacon <will.deacon@arm.com>
1 parent 9af275b commit 4246a86

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

drivers/pci/host/pci-host-common.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,14 @@ int pci_host_common_probe(struct platform_device *pdev,
117117
struct device *dev = &pdev->dev;
118118
struct device_node *np = dev->of_node;
119119
struct pci_bus *bus, *child;
120+
struct pci_host_bridge *bridge;
120121
struct pci_config_window *cfg;
121122
struct list_head resources;
123+
int ret;
124+
125+
bridge = devm_pci_alloc_host_bridge(dev, 0);
126+
if (!bridge)
127+
return -ENOMEM;
122128

123129
type = of_get_property(np, "device_type", NULL);
124130
if (!type || strcmp(type, "pci")) {
@@ -138,13 +144,20 @@ int pci_host_common_probe(struct platform_device *pdev,
138144
if (!pci_has_flag(PCI_PROBE_ONLY))
139145
pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS);
140146

141-
bus = pci_scan_root_bus(dev, cfg->busr.start, &ops->pci_ops, cfg,
142-
&resources);
143-
if (!bus) {
144-
dev_err(dev, "Scanning rootbus failed");
145-
return -ENODEV;
147+
list_splice_init(&resources, &bridge->windows);
148+
bridge->dev.parent = dev;
149+
bridge->sysdata = cfg;
150+
bridge->busnr = cfg->busr.start;
151+
bridge->ops = &ops->pci_ops;
152+
153+
ret = pci_scan_root_bus_bridge(bridge);
154+
if (ret < 0) {
155+
dev_err(dev, "Scanning root bridge failed");
156+
return ret;
146157
}
147158

159+
bus = bridge->bus;
160+
148161
#ifdef CONFIG_ARM
149162
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
150163
#endif

0 commit comments

Comments
 (0)