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 the phy_power_on()
@ 2025-10-15  4:08 Lizhe
  2025-10-15  6:17 ` Chaoyi Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lizhe @ 2025-10-15  4:08 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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 51ea0caf16c1..9d296bfab013 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_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);
 
-- 
2.17.1


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

* Re: [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-10-15  4:08 [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on() Lizhe
@ 2025-10-15  6:17 ` Chaoyi Chen
  2025-10-15  8:59 ` Simon Horman
  2025-10-15 23:43 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Chaoyi Chen @ 2025-10-15  6:17 UTC (permalink / raw)
  To: Lizhe, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, rmk+kernel, jonas, david.wu
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel

On 10/15/2025 12:08 PM, 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
>
> Signed-off-by: Lizhe <sensor1010@163.com>
> ---
>   drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
>   1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 51ea0caf16c1..9d296bfab013 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_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);

Is gmac_clk_enable() also redundant?


> -		return ret;
> -	}
> +	rk_phy_power_on(bsp_priv, true);
>   
>   	pm_runtime_get_sync(dev);
>   

-- 
Best,
Chaoyi


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

* Re: [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-10-15  4:08 [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on() Lizhe
  2025-10-15  6:17 ` Chaoyi Chen
@ 2025-10-15  8:59 ` Simon Horman
  2025-10-15 23:43 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-10-15  8:59 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 09:08:47PM -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
> 
> Signed-off-by: Lizhe <sensor1010@163.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 51ea0caf16c1..9d296bfab013 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_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.

-- 
pw-bot: changes-requested

...

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

* Re: [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-10-15  4:08 [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on() Lizhe
  2025-10-15  6:17 ` Chaoyi Chen
  2025-10-15  8:59 ` Simon Horman
@ 2025-10-15 23:43 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-15 23:43 UTC (permalink / raw)
  To: Lizhe, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, rmk+kernel, jonas, chaoyi.chen,
	david.wu
  Cc: oe-kbuild-all, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Lizhe

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/202510160726.OejMgsW0-lkp@intel.com/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/202510160726.OejMgsW0-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510160726.OejMgsW0-lkp@intel.com/

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  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-10-15 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15  4:08 [PATCH net-next] net: dwmac-rk: No need to check the return value of the phy_power_on() Lizhe
2025-10-15  6:17 ` Chaoyi Chen
2025-10-15  8:59 ` Simon Horman
2025-10-15 23:43 ` kernel test robot

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).