diff mbox series

soc/tegra: pmc: Fix and simplify resource lookup

Message ID 20240517142617.18685-1-jonathanh@nvidia.com
State New
Headers show
Series soc/tegra: pmc: Fix and simplify resource lookup | expand

Commit Message

Jon Hunter May 17, 2024, 2:26 p.m. UTC
Commit 6f4429e21a7f ("soc/tegra: pmc: Update address mapping sequence
for PMC apertures") updated the resource lookup code in the PMC driver
and after this change, the return value from the function
platform_get_resource_byname() for 'wake' and 'aotag' regions is no
longer checked. Fix this by replacing the calls to
platform_get_resource_byname() and devm_ioremap_resource() with
devm_platform_ioremap_resource_byname().

Fixes: 6f4429e21a7f ("soc/tegra: pmc: Update address mapping sequence for PMC apertures")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/soc/tegra/pmc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Jon Hunter June 11, 2024, 7:54 a.m. UTC | #1
On 17/05/2024 15:26, Jon Hunter wrote:
> Commit 6f4429e21a7f ("soc/tegra: pmc: Update address mapping sequence
> for PMC apertures") updated the resource lookup code in the PMC driver
> and after this change, the return value from the function
> platform_get_resource_byname() for 'wake' and 'aotag' regions is no
> longer checked. Fix this by replacing the calls to
> platform_get_resource_byname() and devm_ioremap_resource() with
> devm_platform_ioremap_resource_byname().
> 
> Fixes: 6f4429e21a7f ("soc/tegra: pmc: Update address mapping sequence for PMC apertures")
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>   drivers/soc/tegra/pmc.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 91d0ad6ddefc..6c37d6eb8b49 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -2891,15 +2891,11 @@ static int tegra_pmc_probe(struct platform_device *pdev)
>   		pmc->aotag = base;
>   		pmc->scratch = base;
>   	} else {
> -		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> -						"wake");
> -		pmc->wake = devm_ioremap_resource(&pdev->dev, res);
> +		pmc->wake = devm_platform_ioremap_resource_byname(pdev, "wake");
>   		if (IS_ERR(pmc->wake))
>   			return PTR_ERR(pmc->wake);
>   
> -		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> -						"aotag");
> -		pmc->aotag = devm_ioremap_resource(&pdev->dev, res);
> +		pmc->aotag = devm_platform_ioremap_resource_byname(pdev, "aotag");
>   		if (IS_ERR(pmc->aotag))
>   			return PTR_ERR(pmc->aotag);
>   

I guess this is no quite accurate, because on further inspection the 
above code behaves the same as devm_platform_ioremap_resource_byname(). 
However, we can simplify this code by just using 
devm_platform_ioremap_resource_byname(). I will resend this and update 
the commit message.

Jon
diff mbox series

Patch

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 91d0ad6ddefc..6c37d6eb8b49 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -2891,15 +2891,11 @@  static int tegra_pmc_probe(struct platform_device *pdev)
 		pmc->aotag = base;
 		pmc->scratch = base;
 	} else {
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						"wake");
-		pmc->wake = devm_ioremap_resource(&pdev->dev, res);
+		pmc->wake = devm_platform_ioremap_resource_byname(pdev, "wake");
 		if (IS_ERR(pmc->wake))
 			return PTR_ERR(pmc->wake);
 
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						"aotag");
-		pmc->aotag = devm_ioremap_resource(&pdev->dev, res);
+		pmc->aotag = devm_platform_ioremap_resource_byname(pdev, "aotag");
 		if (IS_ERR(pmc->aotag))
 			return PTR_ERR(pmc->aotag);