Skip to content

Commit 2ce107e

Browse files
committed
PCI: dwc: Consolidate devicetree handling in dw_pcie_host_get_resources()
Consolidate devicetree resource handling in dw_pcie_host_get_resources(). No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Frank Li <[email protected]>
1 parent 84f37c4 commit 2ce107e

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,25 +418,15 @@ static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp)
418418
}
419419
}
420420

421-
int dw_pcie_host_init(struct dw_pcie_rp *pp)
421+
static int dw_pcie_host_get_resources(struct dw_pcie_rp *pp)
422422
{
423423
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
424424
struct device *dev = pci->dev;
425-
struct device_node *np = dev->of_node;
426425
struct platform_device *pdev = to_platform_device(dev);
427426
struct resource_entry *win;
428-
struct pci_host_bridge *bridge;
429427
struct resource *res;
430428
int ret;
431429

432-
raw_spin_lock_init(&pp->lock);
433-
434-
bridge = devm_pci_alloc_host_bridge(dev, 0);
435-
if (!bridge)
436-
return -ENOMEM;
437-
438-
pp->bridge = bridge;
439-
440430
ret = dw_pcie_get_resources(pci);
441431
if (ret)
442432
return ret;
@@ -455,13 +445,36 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
455445
return PTR_ERR(pp->va_cfg0_base);
456446

457447
/* Get the I/O range from DT */
458-
win = resource_list_first_type(&bridge->windows, IORESOURCE_IO);
448+
win = resource_list_first_type(&pp->bridge->windows, IORESOURCE_IO);
459449
if (win) {
460450
pp->io_size = resource_size(win->res);
461451
pp->io_bus_addr = win->res->start - win->offset;
462452
pp->io_base = pci_pio_to_address(win->res->start);
463453
}
464454

455+
return 0;
456+
}
457+
458+
int dw_pcie_host_init(struct dw_pcie_rp *pp)
459+
{
460+
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
461+
struct device *dev = pci->dev;
462+
struct device_node *np = dev->of_node;
463+
struct pci_host_bridge *bridge;
464+
int ret;
465+
466+
raw_spin_lock_init(&pp->lock);
467+
468+
bridge = devm_pci_alloc_host_bridge(dev, 0);
469+
if (!bridge)
470+
return -ENOMEM;
471+
472+
pp->bridge = bridge;
473+
474+
ret = dw_pcie_host_get_resources(pp);
475+
if (ret)
476+
return ret;
477+
465478
/* Set default bus ops */
466479
bridge->ops = &dw_pcie_ops;
467480
bridge->child_ops = &dw_child_pcie_ops;

0 commit comments

Comments
 (0)