diff mbox

[1/7] PCI: tegra: replace devm_request_and_ioremap by devm_ioremap_resource

Message ID alpine.DEB.2.02.1308201112400.2269@hadrien (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Julia Lawall Aug. 20, 2013, 9:13 a.m. UTC
From: Julia Lawall <Julia.Lawall@lip6.fr>

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 <thierry.reding@gmail.com>
Tested-by: Thierry Reding <thierry.reding@gmail.com>

---
v2: add the change to the comment

 drivers/pci/host/pci-tegra.c |   31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Bjorn Helgaas Aug. 20, 2013, 4:26 p.m. UTC | #1
On Tue, Aug 20, 2013 at 3:13 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> 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 <thierry.reding@gmail.com>
> Tested-by: Thierry Reding <thierry.reding@gmail.com>

I'm hoping this goes via arm-soc.  Let me know if you need me to do
something.  If you need it:

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
> v2: add the change to the comment
>
>  drivers/pci/host/pci-tegra.c |   31 ++++++++++---------------------
>  1 file changed, 10 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
> index 7356741..2e9888a 100644
> --- a/drivers/pci/host/pci-tegra.c
> +++ b/drivers/pci/host/pci-tegra.c
> @@ -1031,32 +1031,21 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
>                 return err;
>         }
>
> -       /* request and remap controller registers */
>         pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
> -       if (!pads) {
> -               err = -EADDRNOTAVAIL;
> +       pcie->pads = devm_ioremap_resource(&pdev->dev, pads);
> +       if (IS_ERR(pcie->pads)) {
> +               err = PTR_ERR(pcie->pads);
>                 goto poweroff;
>         }
>
>         afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
> -       if (!afi) {
> -               err = -EADDRNOTAVAIL;
> -               goto poweroff;
> -       }
> -
> -       pcie->pads = devm_request_and_ioremap(&pdev->dev, pads);
> -       if (!pcie->pads) {
> -               err = -EADDRNOTAVAIL;
> -               goto poweroff;
> -       }
> -
> -       pcie->afi = devm_request_and_ioremap(&pdev->dev, afi);
> -       if (!pcie->afi) {
> -               err = -EADDRNOTAVAIL;
> +       pcie->afi = devm_ioremap_resource(&pdev->dev, afi);
> +       if (IS_ERR(pcie->afi)) {
> +               err = PTR_ERR(pcie->afi);
>                 goto poweroff;
>         }
>
> -       /* request and remap configuration space */
> +       /* request configuration space, but remap later, on demand */
>         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
>         if (!res) {
>                 err = -EADDRNOTAVAIL;
> @@ -1492,9 +1481,9 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
>                 rp->lanes = value;
>                 rp->pcie = pcie;
>
> -               rp->base = devm_request_and_ioremap(pcie->dev, &rp->regs);
> -               if (!rp->base)
> -                       return -EADDRNOTAVAIL;
> +               rp->base = devm_ioremap_resource(pcie->dev, &rp->regs);
> +               if (IS_ERR(rp->base))
> +                       return PTR_ERR(rp->base);
>
>                 list_add_tail(&rp->list, &pcie->ports);
>         }
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Warren Aug. 20, 2013, 6:53 p.m. UTC | #2
On 08/20/2013 10:26 AM, Bjorn Helgaas wrote:
> On Tue, Aug 20, 2013 at 3:13 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> From: Julia Lawall <Julia.Lawall@lip6.fr>
>>
>> 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 <thierry.reding@gmail.com>
>> Tested-by: Thierry Reding <thierry.reding@gmail.com>
> 
> I'm hoping this goes via arm-soc.  Let me know if you need me to do
> something.  If you need it:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

In that case, Thierry, can you please bounce it to arm@kernel.org to be
applied on top of wherever Tegra's for-3.12/soc branch was merged.

Acked-by: Stephen Warren <swarren@nvidia.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thierry Reding Aug. 20, 2013, 7:31 p.m. UTC | #3
On Tue, Aug 20, 2013 at 12:53:32PM -0600, Stephen Warren wrote:
> On 08/20/2013 10:26 AM, Bjorn Helgaas wrote:
> > On Tue, Aug 20, 2013 at 3:13 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> From: Julia Lawall <Julia.Lawall@lip6.fr>
> >>
> >> 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 <thierry.reding@gmail.com>
> >> Tested-by: Thierry Reding <thierry.reding@gmail.com>
> > 
> > I'm hoping this goes via arm-soc.  Let me know if you need me to do
> > something.  If you need it:
> > 
> > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> In that case, Thierry, can you please bounce it to arm@kernel.org to be
> applied on top of wherever Tegra's for-3.12/soc branch was merged.
> 
> Acked-by: Stephen Warren <swarren@nvidia.com>

Yes, I can do that. Thanks everyone.

Thierry
diff mbox

Patch

diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 7356741..2e9888a 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -1031,32 +1031,21 @@  static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
 		return err;
 	}

-	/* request and remap controller registers */
 	pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads");
-	if (!pads) {
-		err = -EADDRNOTAVAIL;
+	pcie->pads = devm_ioremap_resource(&pdev->dev, pads);
+	if (IS_ERR(pcie->pads)) {
+		err = PTR_ERR(pcie->pads);
 		goto poweroff;
 	}

 	afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi");
-	if (!afi) {
-		err = -EADDRNOTAVAIL;
-		goto poweroff;
-	}
-
-	pcie->pads = devm_request_and_ioremap(&pdev->dev, pads);
-	if (!pcie->pads) {
-		err = -EADDRNOTAVAIL;
-		goto poweroff;
-	}
-
-	pcie->afi = devm_request_and_ioremap(&pdev->dev, afi);
-	if (!pcie->afi) {
-		err = -EADDRNOTAVAIL;
+	pcie->afi = devm_ioremap_resource(&pdev->dev, afi);
+	if (IS_ERR(pcie->afi)) {
+		err = PTR_ERR(pcie->afi);
 		goto poweroff;
 	}

-	/* request and remap configuration space */
+	/* request configuration space, but remap later, on demand */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cs");
 	if (!res) {
 		err = -EADDRNOTAVAIL;
@@ -1492,9 +1481,9 @@  static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
 		rp->lanes = value;
 		rp->pcie = pcie;

-		rp->base = devm_request_and_ioremap(pcie->dev, &rp->regs);
-		if (!rp->base)
-			return -EADDRNOTAVAIL;
+		rp->base = devm_ioremap_resource(pcie->dev, &rp->regs);
+		if (IS_ERR(rp->base))
+			return PTR_ERR(rp->base);

 		list_add_tail(&rp->list, &pcie->ports);
 	}