Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Julia Lawall and committed by
Olof Johansson
dc05ee32 e8a72e2a

+10 -21
+10 -21
drivers/pci/host/pci-tegra.c
··· 1031 1031 return err; 1032 1032 } 1033 1033 1034 - /* request and remap controller registers */ 1035 1034 pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads"); 1036 - if (!pads) { 1037 - err = -EADDRNOTAVAIL; 1035 + pcie->pads = devm_ioremap_resource(&pdev->dev, pads); 1036 + if (IS_ERR(pcie->pads)) { 1037 + err = PTR_ERR(pcie->pads); 1038 1038 goto poweroff; 1039 1039 } 1040 1040 1041 1041 afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi"); 1042 - if (!afi) { 1043 - err = -EADDRNOTAVAIL; 1042 + pcie->afi = devm_ioremap_resource(&pdev->dev, afi); 1043 + if (IS_ERR(pcie->afi)) { 1044 + err = PTR_ERR(pcie->afi); 1044 1045 goto poweroff; 1045 1046 } 1046 1047 1047 - pcie->pads = devm_request_and_ioremap(&pdev->dev, pads); 1048 - if (!pcie->pads) { 1049 - err = -EADDRNOTAVAIL; 1050 - goto poweroff; 1051 - } 1052 - 1053 - pcie->afi = devm_request_and_ioremap(&pdev->dev, afi); 1054 - if (!pcie->afi) { 1055 - err = -EADDRNOTAVAIL; 1056 - goto poweroff; 1057 - } 1058 - 1059 - /* request and remap configuration space */ 1048 + /* request configuration space, but remap later, on demand */ 1060 1049 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs"); 1061 1050 if (!res) { 1062 1051 err = -EADDRNOTAVAIL; ··· 1481 1492 rp->lanes = value; 1482 1493 rp->pcie = pcie; 1483 1494 1484 - rp->base = devm_request_and_ioremap(pcie->dev, &rp->regs); 1485 - if (!rp->base) 1486 - return -EADDRNOTAVAIL; 1495 + rp->base = devm_ioremap_resource(pcie->dev, &rp->regs); 1496 + if (IS_ERR(rp->base)) 1497 + return PTR_ERR(rp->base); 1487 1498 1488 1499 list_add_tail(&rp->list, &pcie->ports); 1489 1500 }