[PATCH 1/2] phy: marvell: a3700-comphy: Use devm_platform_ioremap_resource_byname

shao.mingyin@zte.com.cn posted 2 patches 1 month, 1 week ago
[PATCH 1/2] phy: marvell: a3700-comphy: Use devm_platform_ioremap_resource_byname
Posted by shao.mingyin@zte.com.cn 1 month, 1 week ago
From: Xie Ludan <xie.ludan@zte.com.cn>

Introduce devm_platform_ioremap_resource_byname() to simplify resource
retrieval and mapping.This new function consolidates
platform_get_resource_byname() and devm_ioremap_resource() into
a single call, improving code readability and reducing API call overhead.

Signed-off-by: Xie Ludan <xie.ludan@zte.com.cn>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
 drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
index 1d1db1737422..e629a1a73214 100644
--- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
+++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
@@ -1253,26 +1253,20 @@ static int mvebu_a3700_comphy_probe(struct platform_device *pdev)

 	spin_lock_init(&priv->lock);

-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "comphy");
-	priv->comphy_regs = devm_ioremap_resource(&pdev->dev, res);
+	priv->comphy_regs = devm_platform_ioremap_resource_byname(pdev, "comphy");
 	if (IS_ERR(priv->comphy_regs))
 		return PTR_ERR(priv->comphy_regs);

-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-					   "lane1_pcie_gbe");
-	priv->lane1_phy_regs = devm_ioremap_resource(&pdev->dev, res);
+	priv->lane1_phy_regs = devm_platform_ioremap_resource_byname(pdev, "lane1_pcie_gbe");
 	if (IS_ERR(priv->lane1_phy_regs))
 		return PTR_ERR(priv->lane1_phy_regs);

-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-					   "lane0_usb3_gbe");
-	priv->lane0_phy_regs = devm_ioremap_resource(&pdev->dev, res);
+	priv->lane0_phy_regs = devm_platform_ioremap_resource_byname(pdev, "lane0_usb3_gbe");
 	if (IS_ERR(priv->lane0_phy_regs))
 		return PTR_ERR(priv->lane0_phy_regs);

-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-					   "lane2_sata_usb3");
-	priv->lane2_phy_indirect = devm_ioremap_resource(&pdev->dev, res);
+	priv->lane2_phy_indirect = devm_platform_ioremap_resource_byname(pdev,
+									 "lane2_sata_usb3");
 	if (IS_ERR(priv->lane2_phy_indirect))
 		return PTR_ERR(priv->lane2_phy_indirect);

-- 
2.25.1
Re: [PATCH 1/2] phy: marvell: a3700-comphy: Use devm_platform_ioremap_resource_byname
Posted by Vinod Koul 1 month ago
On 01-04-25, 19:38, shao.mingyin@zte.com.cn wrote:
> From: Xie Ludan <xie.ludan@zte.com.cn>
> 
> Introduce devm_platform_ioremap_resource_byname() to simplify resource
> retrieval and mapping.This new function consolidates
> platform_get_resource_byname() and devm_ioremap_resource() into
> a single call, improving code readability and reducing API call overhead.
> 
> Signed-off-by: Xie Ludan <xie.ludan@zte.com.cn>
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
>  drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> index 1d1db1737422..e629a1a73214 100644
> --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> @@ -1253,26 +1253,20 @@ static int mvebu_a3700_comphy_probe(struct platform_device *pdev)
> 
>  	spin_lock_init(&priv->lock);
> 
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "comphy");

res is unused so this should lead to warnings by this patch, did you at
least compile test it?

> -	priv->comphy_regs = devm_ioremap_resource(&pdev->dev, res);
> +	priv->comphy_regs = devm_platform_ioremap_resource_byname(pdev, "comphy");
>  	if (IS_ERR(priv->comphy_regs))
>  		return PTR_ERR(priv->comphy_regs);
> 
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> -					   "lane1_pcie_gbe");
> -	priv->lane1_phy_regs = devm_ioremap_resource(&pdev->dev, res);
> +	priv->lane1_phy_regs = devm_platform_ioremap_resource_byname(pdev, "lane1_pcie_gbe");
>  	if (IS_ERR(priv->lane1_phy_regs))
>  		return PTR_ERR(priv->lane1_phy_regs);
> 
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> -					   "lane0_usb3_gbe");
> -	priv->lane0_phy_regs = devm_ioremap_resource(&pdev->dev, res);
> +	priv->lane0_phy_regs = devm_platform_ioremap_resource_byname(pdev, "lane0_usb3_gbe");
>  	if (IS_ERR(priv->lane0_phy_regs))
>  		return PTR_ERR(priv->lane0_phy_regs);
> 
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> -					   "lane2_sata_usb3");
> -	priv->lane2_phy_indirect = devm_ioremap_resource(&pdev->dev, res);
> +	priv->lane2_phy_indirect = devm_platform_ioremap_resource_byname(pdev,
> +									 "lane2_sata_usb3");
>  	if (IS_ERR(priv->lane2_phy_indirect))
>  		return PTR_ERR(priv->lane2_phy_indirect);
> 
> -- 
> 2.25.1

-- 
~Vinod
Re: [PATCH 1/2] phy: marvell: a3700-comphy:Use devm_platform_ioremap_resource_byname
Posted by Miquel Raynal 1 month, 1 week ago
On 01/04/2025 at 19:38:36 +08, <shao.mingyin@zte.com.cn> wrote:

> From: Xie Ludan <xie.ludan@zte.com.cn>
>
> Introduce devm_platform_ioremap_resource_byname() to simplify resource
> retrieval and mapping.This new function consolidates
> platform_get_resource_byname() and devm_ioremap_resource() into
> a single call, improving code readability and reducing API call overhead.
>
> Signed-off-by: Xie Ludan <xie.ludan@zte.com.cn>
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl