Skip to content

Commit e2dcd20

Browse files
Dejin ZhengLorenzo Pieralisi
authored andcommitted
PCI: controller: Convert to devm_platform_ioremap_resource_byname()
Use devm_platform_ioremap_resource_byname() to simplify the code, since it calls respectively platform_get_resource_byname() and devm_ioremap_resource(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dejin Zheng <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Rob Herring <[email protected]> Reviewed-by: Gustavo Pimentel <[email protected]>
1 parent 78aada4 commit e2dcd20

File tree

8 files changed

+13
-25
lines changed

8 files changed

+13
-25
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)
408408

409409
pcie->is_rc = false;
410410

411-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg");
412-
pcie->reg_base = devm_ioremap_resource(dev, res);
411+
pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg");
413412
if (IS_ERR(pcie->reg_base)) {
414413
dev_err(dev, "missing \"reg\"\n");
415414
return PTR_ERR(pcie->reg_base);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
217217
rc->device_id = 0xffff;
218218
of_property_read_u32(np, "device-id", &rc->device_id);
219219

220-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg");
221-
pcie->reg_base = devm_ioremap_resource(dev, res);
220+
pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg");
222221
if (IS_ERR(pcie->reg_base)) {
223222
dev_err(dev, "missing \"reg\"\n");
224223
return PTR_ERR(pcie->reg_base);

drivers/pci/controller/pci-tegra.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
14621462
{
14631463
struct device *dev = pcie->dev;
14641464
struct platform_device *pdev = to_platform_device(dev);
1465-
struct resource *pads, *afi, *res;
1465+
struct resource *res;
14661466
const struct tegra_pcie_soc *soc = pcie->soc;
14671467
int err;
14681468

@@ -1486,15 +1486,13 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
14861486
}
14871487
}
14881488

1489-
pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
1490-
pcie->pads = devm_ioremap_resource(dev, pads);
1489+
pcie->pads = devm_platform_ioremap_resource_byname(pdev, "pads");
14911490
if (IS_ERR(pcie->pads)) {
14921491
err = PTR_ERR(pcie->pads);
14931492
goto phys_put;
14941493
}
14951494

1496-
afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
1497-
pcie->afi = devm_ioremap_resource(dev, afi);
1495+
pcie->afi = devm_platform_ioremap_resource_byname(pdev, "afi");
14981496
if (IS_ERR(pcie->afi)) {
14991497
err = PTR_ERR(pcie->afi);
15001498
goto phys_put;

drivers/pci/controller/pci-xgene.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ static int xgene_pcie_map_reg(struct xgene_pcie_port *port,
355355
if (IS_ERR(port->csr_base))
356356
return PTR_ERR(port->csr_base);
357357

358-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
359-
port->cfg_base = devm_ioremap_resource(dev, res);
358+
port->cfg_base = devm_platform_ioremap_resource_byname(pdev, "cfg");
360359
if (IS_ERR(port->cfg_base))
361360
return PTR_ERR(port->cfg_base);
362361
port->cfg_addr = res->start;

drivers/pci/controller/pcie-altera-msi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ static int altera_msi_probe(struct platform_device *pdev)
228228
mutex_init(&msi->lock);
229229
msi->pdev = pdev;
230230

231-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csr");
232-
msi->csr_base = devm_ioremap_resource(&pdev->dev, res);
231+
msi->csr_base = devm_platform_ioremap_resource_byname(pdev, "csr");
233232
if (IS_ERR(msi->csr_base)) {
234233
dev_err(&pdev->dev, "failed to map csr memory\n");
235234
return PTR_ERR(msi->csr_base);

drivers/pci/controller/pcie-altera.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,17 +696,14 @@ static int altera_pcie_parse_dt(struct altera_pcie *pcie)
696696
{
697697
struct device *dev = &pcie->pdev->dev;
698698
struct platform_device *pdev = pcie->pdev;
699-
struct resource *cra;
700-
struct resource *hip;
701699

702-
cra = platform_get_resource_byname(pdev, IORESOURCE_MEM, "Cra");
703-
pcie->cra_base = devm_ioremap_resource(dev, cra);
700+
pcie->cra_base = devm_platform_ioremap_resource_byname(pdev, "Cra");
704701
if (IS_ERR(pcie->cra_base))
705702
return PTR_ERR(pcie->cra_base);
706703

707704
if (pcie->pcie_data->version == ALTERA_PCIE_V2) {
708-
hip = platform_get_resource_byname(pdev, IORESOURCE_MEM, "Hip");
709-
pcie->hip_base = devm_ioremap_resource(&pdev->dev, hip);
705+
pcie->hip_base =
706+
devm_platform_ioremap_resource_byname(pdev, "Hip");
710707
if (IS_ERR(pcie->hip_base))
711708
return PTR_ERR(pcie->hip_base);
712709
}

drivers/pci/controller/pcie-mediatek.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,6 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
905905
int slot)
906906
{
907907
struct mtk_pcie_port *port;
908-
struct resource *regs;
909908
struct device *dev = pcie->dev;
910909
struct platform_device *pdev = to_platform_device(dev);
911910
char name[10];
@@ -916,8 +915,7 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
916915
return -ENOMEM;
917916

918917
snprintf(name, sizeof(name), "port%d", slot);
919-
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
920-
port->base = devm_ioremap_resource(dev, regs);
918+
port->base = devm_platform_ioremap_resource_byname(pdev, name);
921919
if (IS_ERR(port->base)) {
922920
dev_err(dev, "failed to map port%d base\n", slot);
923921
return PTR_ERR(port->base);

drivers/pci/controller/pcie-rockchip.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
4545
return -EINVAL;
4646
}
4747

48-
regs = platform_get_resource_byname(pdev, IORESOURCE_MEM,
49-
"apb-base");
50-
rockchip->apb_base = devm_ioremap_resource(dev, regs);
48+
rockchip->apb_base =
49+
devm_platform_ioremap_resource_byname(pdev, "apb-base");
5150
if (IS_ERR(rockchip->apb_base))
5251
return PTR_ERR(rockchip->apb_base);
5352

0 commit comments

Comments
 (0)