Skip to content

Commit 5c1306a

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: rockchip: Use pci_parse_request_of_pci_ranges()
Convert the Rockchip host bridge to use the common pci_parse_request_of_pci_ranges(). There's no need to assign the resources to a temporary list first. Just use bridge->windows directly and remove all the temporary list handling. Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Cc: Shawn Lin <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Andrew Murray <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Heiko Stuebner <[email protected]> Cc: [email protected]
1 parent 6c6a0df commit 5c1306a

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -950,14 +950,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
950950
struct device *dev = &pdev->dev;
951951
struct pci_bus *bus, *child;
952952
struct pci_host_bridge *bridge;
953+
struct resource *bus_res;
953954
struct resource_entry *win;
954-
resource_size_t io_base;
955-
struct resource *mem;
956-
struct resource *io;
957955
int err;
958956

959-
LIST_HEAD(res);
960-
961957
if (!dev->of_node)
962958
return -ENODEV;
963959

@@ -995,29 +991,20 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
995991
if (err < 0)
996992
goto err_deinit_port;
997993

998-
err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
999-
&res, &io_base);
994+
err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, &bus_res);
1000995
if (err)
1001996
goto err_remove_irq_domain;
1002997

1003-
err = devm_request_pci_bus_resources(dev, &res);
1004-
if (err)
1005-
goto err_free_res;
998+
rockchip->root_bus_nr = bus_res->start;
1006999

10071000
/* Get the I/O and memory ranges from DT */
1008-
resource_list_for_each_entry(win, &res) {
1001+
resource_list_for_each_entry(win, &bridge->windows) {
10091002
switch (resource_type(win->res)) {
10101003
case IORESOURCE_IO:
10111004
io = win->res;
10121005
io->name = "I/O";
10131006
rockchip->io_size = resource_size(io);
10141007
rockchip->io_bus_addr = io->start - win->offset;
1015-
err = pci_remap_iospace(io, io_base);
1016-
if (err) {
1017-
dev_warn(dev, "error %d: failed to map resource %pR\n",
1018-
err, io);
1019-
continue;
1020-
}
10211008
rockchip->io = io;
10221009
break;
10231010
case IORESOURCE_MEM:
@@ -1026,25 +1013,21 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
10261013
rockchip->mem_size = resource_size(mem);
10271014
rockchip->mem_bus_addr = mem->start - win->offset;
10281015
break;
1029-
case IORESOURCE_BUS:
1030-
rockchip->root_bus_nr = win->res->start;
1031-
break;
10321016
default:
10331017
continue;
10341018
}
10351019
}
10361020

10371021
err = rockchip_pcie_cfg_atu(rockchip);
10381022
if (err)
1039-
goto err_unmap_iospace;
1023+
goto err_remove_irq_domain;
10401024

10411025
rockchip->msg_region = devm_ioremap(dev, rockchip->msg_bus_addr, SZ_1M);
10421026
if (!rockchip->msg_region) {
10431027
err = -ENOMEM;
1044-
goto err_unmap_iospace;
1028+
goto err_remove_irq_domain;
10451029
}
10461030

1047-
list_splice_init(&res, &bridge->windows);
10481031
bridge->dev.parent = dev;
10491032
bridge->sysdata = rockchip;
10501033
bridge->busnr = 0;
@@ -1054,7 +1037,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
10541037

10551038
err = pci_scan_root_bus_bridge(bridge);
10561039
if (err < 0)
1057-
goto err_unmap_iospace;
1040+
goto err_remove_irq_domain;
10581041

10591042
bus = bridge->bus;
10601043

@@ -1068,10 +1051,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
10681051
pci_bus_add_devices(bus);
10691052
return 0;
10701053

1071-
err_unmap_iospace:
1072-
pci_unmap_iospace(rockchip->io);
1073-
err_free_res:
1074-
pci_free_resource_list(&res);
10751054
err_remove_irq_domain:
10761055
irq_domain_remove(rockchip->irq_domain);
10771056
err_deinit_port:
@@ -1097,7 +1076,6 @@ static int rockchip_pcie_remove(struct platform_device *pdev)
10971076

10981077
pci_stop_root_bus(rockchip->root_bus);
10991078
pci_remove_root_bus(rockchip->root_bus);
1100-
pci_unmap_iospace(rockchip->io);
11011079
irq_domain_remove(rockchip->irq_domain);
11021080

11031081
rockchip_pcie_deinit_phys(rockchip);

0 commit comments

Comments
 (0)