PCI: tegra: replace devm_request_and_ioremap by devm_ioremap_resource

Use devm_ioremap_resource instead of devm_request_and_ioremap.

This was done using the semantic patch
scripts/coccinelle/api/devm_ioremap_resource.cocci

Error-handling code was manually removed from the associated calls to
platform_get_resource.

Adjust the comment at the third platform_get_resource_byname to make clear
why ioremap is not done at this point.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Thierry Reding <treding@nvidia.com>
Tested-by: Thierry Reding <treding@nvidia.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
Julia Lawall 2013-08-26 11:11:09 +02:00 committed by Olof Johansson
parent e8a72e2a5d
commit dc05ee3298

View File

@ -1031,32 +1031,21 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
return err; return err;
} }
/* request and remap controller registers */
pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads"); pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
if (!pads) { pcie->pads = devm_ioremap_resource(&pdev->dev, pads);
err = -EADDRNOTAVAIL; if (IS_ERR(pcie->pads)) {
err = PTR_ERR(pcie->pads);
goto poweroff; goto poweroff;
} }
afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi"); afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
if (!afi) { pcie->afi = devm_ioremap_resource(&pdev->dev, afi);
err = -EADDRNOTAVAIL; if (IS_ERR(pcie->afi)) {
err = PTR_ERR(pcie->afi);
goto poweroff; goto poweroff;
} }
pcie->pads = devm_request_and_ioremap(&pdev->dev, pads); /* request configuration space, but remap later, on demand */
if (!pcie->pads) {
err = -EADDRNOTAVAIL;
goto poweroff;
}
pcie->afi = devm_request_and_ioremap(&pdev->dev, afi);
if (!pcie->afi) {
err = -EADDRNOTAVAIL;
goto poweroff;
}
/* request and remap configuration space */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
if (!res) { if (!res) {
err = -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
@ -1492,9 +1481,9 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
rp->lanes = value; rp->lanes = value;
rp->pcie = pcie; rp->pcie = pcie;
rp->base = devm_request_and_ioremap(pcie->dev, &rp->regs); rp->base = devm_ioremap_resource(pcie->dev, &rp->regs);
if (!rp->base) if (IS_ERR(rp->base))
return -EADDRNOTAVAIL; return PTR_ERR(rp->base);
list_add_tail(&rp->list, &pcie->ports); list_add_tail(&rp->list, &pcie->ports);
} }