Skip to content

Commit 669cbc7

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: Move DT resource setup into devm_pci_alloc_host_bridge()
Now that pci_parse_request_of_pci_ranges() callers just setup pci_host_bridge.windows and dma_ranges directly and don't need the bus range returned, we can just initialize them when allocating the pci_host_bridge struct. With this, pci_parse_request_of_pci_ranges() becomes a static function. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Bjorn Helgaas <[email protected]>
1 parent 4a95756 commit 669cbc7

24 files changed

+36
-155
lines changed

drivers/pci/controller/cadence/pcie-cadence-host.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,8 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)
171171
static int cdns_pcie_host_init(struct device *dev,
172172
struct cdns_pcie_rc *rc)
173173
{
174-
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(rc);
175174
int err;
176175

177-
/* Parse our PCI ranges and request their resources */
178-
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL, NULL);
179-
if (err)
180-
return err;
181-
182176
err = cdns_pcie_host_init_root_port(rc);
183177
if (err)
184178
return err;

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
346346
if (!bridge)
347347
return -ENOMEM;
348348

349-
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
350-
&bridge->dma_ranges, NULL);
351-
if (ret)
352-
return ret;
353-
354349
/* Get the I/O and memory ranges from DT */
355350
resource_list_for_each_entry(win, &bridge->windows) {
356351
switch (resource_type(win->res)) {

drivers/pci/controller/mobiveil/pcie-mobiveil-host.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)
577577
if (!mobiveil_pcie_is_bridge(pcie))
578578
return -ENODEV;
579579

580-
/* parse the host bridge base addresses from the device tree file */
581-
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
582-
&bridge->dma_ranges, NULL);
583-
if (ret) {
584-
dev_err(dev, "Getting bridge resources failed\n");
585-
return ret;
586-
}
587-
588580
/*
589581
* configure all inbound and outbound windows and prepare the RC for
590582
* config access

drivers/pci/controller/pci-aardvark.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,13 +1130,6 @@ static int advk_pcie_probe(struct platform_device *pdev)
11301130
return ret;
11311131
}
11321132

1133-
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
1134-
&bridge->dma_ranges, NULL);
1135-
if (ret) {
1136-
dev_err(dev, "Failed to parse resources\n");
1137-
return ret;
1138-
}
1139-
11401133
pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
11411134
"reset-gpios", 0,
11421135
GPIOD_OUT_LOW,

drivers/pci/controller/pci-ftpci100.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,6 @@ static int faraday_pci_probe(struct platform_device *pdev)
465465
if (IS_ERR(p->base))
466466
return PTR_ERR(p->base);
467467

468-
ret = pci_parse_request_of_pci_ranges(dev, &host->windows,
469-
&host->dma_ranges, NULL);
470-
if (ret)
471-
return ret;
472-
473468
win = resource_list_first_type(&host->windows, IORESOURCE_IO);
474469
if (win) {
475470
io = win->res;

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,20 @@ static struct pci_config_window *gen_pci_init(struct device *dev,
2525
{
2626
int err;
2727
struct resource cfgres;
28-
struct resource *bus_range = NULL;
28+
struct resource_entry *bus;
2929
struct pci_config_window *cfg;
3030

31-
/* Parse our PCI ranges and request their resources */
32-
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL, &bus_range);
33-
if (err)
34-
return ERR_PTR(err);
35-
3631
err = of_address_to_resource(dev->of_node, 0, &cfgres);
3732
if (err) {
3833
dev_err(dev, "missing \"reg\" property\n");
3934
return ERR_PTR(err);
4035
}
4136

42-
cfg = pci_ecam_create(dev, &cfgres, bus_range, ops);
37+
bus = resource_list_first_type(&bridge->windows, IORESOURCE_BUS);
38+
if (!bus)
39+
return ERR_PTR(-ENODEV);
40+
41+
cfg = pci_ecam_create(dev, &cfgres, bus->res, ops);
4342
if (IS_ERR(cfg))
4443
return cfg;
4544

drivers/pci/controller/pci-loongson.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,6 @@ static int loongson_pci_probe(struct platform_device *pdev)
218218
}
219219
}
220220

221-
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
222-
&bridge->dma_ranges, NULL);
223-
if (err) {
224-
dev_err(dev, "failed to get bridge resources\n");
225-
return err;
226-
}
227-
228221
bridge->sysdata = priv;
229222
bridge->ops = &loongson_pci_ops;
230223
bridge->map_irq = loongson_map_irq;

drivers/pci/controller/pci-rcar-gen2.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
282282
struct rcar_pci_priv *priv;
283283
struct pci_host_bridge *bridge;
284284
void __iomem *reg;
285-
int ret;
286285

287286
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*priv));
288287
if (!bridge)
@@ -315,11 +314,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
315314
return priv->irq;
316315
}
317316

318-
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
319-
&bridge->dma_ranges, NULL);
320-
if (ret)
321-
return ret;
322-
323317
bridge->ops = &rcar_pci_ops;
324318

325319
pci_add_flags(PCI_REASSIGN_ALL_BUS);

drivers/pci/controller/pci-tegra.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,12 +2682,6 @@ static int tegra_pcie_probe(struct platform_device *pdev)
26822682
INIT_LIST_HEAD(&pcie->ports);
26832683
pcie->dev = dev;
26842684

2685-
err = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL, NULL);
2686-
if (err) {
2687-
dev_err(dev, "Getting bridge resources failed\n");
2688-
return err;
2689-
}
2690-
26912685
err = tegra_pcie_parse_dt(pcie);
26922686
if (err < 0)
26932687
return err;

drivers/pci/controller/pci-v3-semi.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,6 @@ static int v3_pci_probe(struct platform_device *pdev)
764764
if (IS_ERR(v3->config_base))
765765
return PTR_ERR(v3->config_base);
766766

767-
ret = pci_parse_request_of_pci_ranges(dev, &host->windows,
768-
&host->dma_ranges, NULL);
769-
if (ret)
770-
return ret;
771-
772767
/* Get and request error IRQ resource */
773768
irq = platform_get_irq(pdev, 0);
774769
if (irq < 0) {

0 commit comments

Comments
 (0)