Skip to contentSkip to conversation

net: dwmac-rk: No need to check the return value of the phy_power_on()

PATCH In review Lizhe 4 participants 4 messages Oct 15, 2025

Subsystems (5)
lore
Share & tools
lore

Lizhe

author
#0 lore raw

PATCH 1/1 net: dwmac-rk: No need to check the return value of the phy_power_on()

'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

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +4 -13
index 51ea0caf16c1..9d296bfab013 100644
@@ -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_on(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_on(bsp_priv, true);
 
 	pm_runtime_get_sync(dev);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 46 lines · 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

---
  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
  1 file changed, 4 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +3 -8
index 51ea0caf16c1..9d296bfab013 100644
@@ -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_on(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,

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) · line 1660

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -3
@@ -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);

Is gmac_clk_enable() also redundant?

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -2
-		return ret;
-	}
+	rk_phy_power_on(bsp_priv, true);
 
  	pm_runtime_get_sync(dev);
 
Signature · 2 lines
Best,
Chaoyi
reviewer
#2 lore raw
In reply to Lizhe
Quoted 19 lines · 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

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -0
index 51ea0caf16c1..9d296bfab013 100644

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable) · line 1464

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -1
@@ -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_on(struct rk_priv_data *bsp_priv, bool enable)

Hi Lizhe,

This introduces a compilation error because phy_power_on() is still used on line 1670.

Perhaps the hunk to update that line got lost somewhere.

Signature · 3 lines
pw-bot: changes-requested

...
#3 lore raw
In reply to Lizhe
kernel test robot noticed the following build errors:

Hi Lizhe,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Lizhe/net-dwmac-rk-No-need-to-check-the-return-value-of-the-phy_power_on/20251015-121214
base:   net-next/main
patch link:    https://lore.kernel.org/r/20251015040847.6421-1-sensor1010%40163.com
patch subject: [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on()
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20251016/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251016/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c: In function 'rk_gmac_powerdown':

>> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c:1670:9: error: implicit declaration of function 'phy_power_on'; did you mean 'rk_phy_power_on'? [-Wimplicit-function-declaration]
    1670 |         phy_power_on(gmac, false);
         |         ^~~~~~~~~~~~
         |         rk_phy_power_on

vim +1670 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

7ad269ea1a2b7d Roger Chen            2014-12-29  1662  
229666c14c75ae Vincent Palatin       2016-06-15  1663  static void rk_gmac_powerdown(struct rk_priv_data *gmac)
7ad269ea1a2b7d Roger Chen            2014-12-29  1664  {
32c7bc0747bbd8 Jonas Karlman         2025-03-19  1665  	if (gmac->integrated_phy && gmac->ops->integrated_phy_powerdown)
32c7bc0747bbd8 Jonas Karlman         2025-03-19  1666  		gmac->ops->integrated_phy_powerdown(gmac);
fecd4d7eef8b21 David Wu              2017-08-10  1667  
8f6503993911f0 Russell King (Oracle  2025-06-16  1668) 	pm_runtime_put_sync(gmac->dev);
aec3f415f7244b Punit Agrawal         2021-09-29  1669  
7ad269ea1a2b7d Roger Chen            2014-12-29 @1670  	phy_power_on(gmac, false);
7ad269ea1a2b7d Roger Chen            2014-12-29  1671  	gmac_clk_enable(gmac, false);
7ad269ea1a2b7d Roger Chen            2014-12-29  1672  }
7ad269ea1a2b7d Roger Chen            2014-12-29  1673  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki