netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dwmac-rk: No need to check the return value of phy_power_on()
@ 2025-10-15  5:14 Lizhe
  2025-10-16 12:36 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Lizhe @ 2025-10-15  5:14 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, rmk+kernel, jonas, chaoyi.chen, david.wu
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Lizhe

'phy_power_on' is a local scope one within the driver, since the
return value of the phy_power_on() function is always 0, checking
its return value is redundant.

the function name 'phy_power_on()' conflicts with the existing
phy_power_on() function in the PHY subsystem. a suitable alternative
name would be rk_phy_power_set(), particularly since when the
second argument is false, this function actually powers off the PHY

Signed-off-by: Lizhe <sensor1010@163.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 51ea0caf16c1..ac3324430b2d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1461,23 +1461,18 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 	return 0;
 }
 
-static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
+static void rk_phy_power_set(struct rk_priv_data *bsp_priv, bool enable)
 {
 	struct regulator *ldo = bsp_priv->regulator;
 	struct device *dev = bsp_priv->dev;
-	int ret;
 
 	if (enable) {
-		ret = regulator_enable(ldo);
-		if (ret)
+		if (regulator_enable(ldo))
 			dev_err(dev, "fail to enable phy-supply\n");
 	} else {
-		ret = regulator_disable(ldo);
-		if (ret)
+		if (regulator_disable(ldo))
 			dev_err(dev, "fail to disable phy-supply\n");
 	}
-
-	return 0;
 }
 
 static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
@@ -1655,11 +1650,7 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
 		dev_err(dev, "NO interface defined!\n");
 	}
 
-	ret = phy_power_on(bsp_priv, true);
-	if (ret) {
-		gmac_clk_enable(bsp_priv, false);
-		return ret;
-	}
+	rk_phy_power_set(bsp_priv, true);
 
 	pm_runtime_get_sync(dev);
 
@@ -1676,7 +1667,7 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac)
 
 	pm_runtime_put_sync(gmac->dev);
 
-	phy_power_on(gmac, false);
+	rk_phy_power_set(gmac, false);
 	gmac_clk_enable(gmac, false);
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: dwmac-rk: No need to check the return value of phy_power_on()
  2025-10-15  5:14 [PATCH net-next] net: dwmac-rk: No need to check the return value of phy_power_on() Lizhe
@ 2025-10-16 12:36 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2025-10-16 12:36 UTC (permalink / raw)
  To: Lizhe
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, rmk+kernel, jonas, chaoyi.chen, david.wu,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

On Tue, Oct 14, 2025 at 10:14:46PM -0700, Lizhe wrote:
> 'phy_power_on' is a local scope one within the driver, since the
> return value of the phy_power_on() function is always 0, checking
> its return value is redundant.
> 
> the function name 'phy_power_on()' conflicts with the existing
> phy_power_on() function in the PHY subsystem. a suitable alternative
> name would be rk_phy_power_set(), particularly since when the
> second argument is false, this function actually powers off the PHY

This is two changes. I would lean towards splitting it into
two patches (in a single patch-set).

> 
> Signed-off-by: Lizhe <sensor1010@163.com>

Also, in future, please wait 24h between posting revisions of a patchset.
And note revisions in the subject, like this:

  Subject: [PATCH net-next v2] ...

https://docs.kernel.org/process/maintainer-netdev.html

> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 51ea0caf16c1..ac3324430b2d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1461,23 +1461,18 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
>  	return 0;
>  }
>  
> -static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
> +static void rk_phy_power_set(struct rk_priv_data *bsp_priv, bool enable)
>  {
>  	struct regulator *ldo = bsp_priv->regulator;
>  	struct device *dev = bsp_priv->dev;
> -	int ret;
>  
>  	if (enable) {
> -		ret = regulator_enable(ldo);
> -		if (ret)
> +		if (regulator_enable(ldo))
>  			dev_err(dev, "fail to enable phy-supply\n");
>  	} else {
> -		ret = regulator_disable(ldo);
> -		if (ret)
> +		if (regulator_disable(ldo))
>  			dev_err(dev, "fail to disable phy-supply\n");

The 'ret' changes above don't relate to the patch description.
I'd leave this be. But if you really want to go this way
I think it would be a separate patch.

>  	}
> -
> -	return 0;
>  }
>  
>  static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,

-- 
pw-bot: changes-requested

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-16 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15  5:14 [PATCH net-next] net: dwmac-rk: No need to check the return value of phy_power_on() Lizhe
2025-10-16 12:36 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).