linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
@ 2025-05-26 16:16 李哲
  2025-05-26 17:05 ` Andrew Lunn
  2025-05-27  5:43 ` Christophe JAILLET
  0 siblings, 2 replies; 6+ messages in thread
From: 李哲 @ 2025-05-26 16:16 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, wens, jan.petrous
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	李哲

since the return value of the phy_power_on() function is always 0,
checking its return value is redundant.

Signed-off-by: 李哲 <sensor1010@163.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 700858ff6f7c..6e8b10fda24d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1839,11 +1839,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;
-	}
+	phy_power_on(bsp_priv, true);
 
 	pm_runtime_get_sync(dev);
 
-- 
2.17.1



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

* Re: [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-05-26 16:16 李哲
@ 2025-05-26 17:05 ` Andrew Lunn
  2025-05-27  5:43 ` Christophe JAILLET
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2025-05-26 17:05 UTC (permalink / raw)
  To: 李哲
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, wens, jan.petrous,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

On Mon, May 26, 2025 at 09:16:21AM -0700, 李哲 wrote:
> since the return value of the phy_power_on() function is always 0,
> checking its return value is redundant.
> 
> Signed-off-by: 李哲 <sensor1010@163.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 700858ff6f7c..6e8b10fda24d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1839,11 +1839,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;
> -	}
> +	phy_power_on(bsp_priv, true);

I suggest you go one step further and turn phy_power_on() into a void
function.

net-next is closed for the next two week due to the merge window.

	Andrew


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

* Re: [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-05-26 16:16 李哲
  2025-05-26 17:05 ` Andrew Lunn
@ 2025-05-27  5:43 ` Christophe JAILLET
  2025-05-27 13:14   ` Andrew Lunn
  1 sibling, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2025-05-27  5:43 UTC (permalink / raw)
  To: 李哲, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, jonas, rmk+kernel, david.wu,
	wens, jan.petrous
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel

Le 26/05/2025 à 18:16, 李哲 a écrit :
> since the return value of the phy_power_on() function is always 0,
> checking its return value is redundant.

Can you elaborate why?

Looking at  (1], I think that it is obvious that non-0 values can be 
returned.


CJ

[1]: 
https://elixir.bootlin.com/linux/v6.15/source/drivers/phy/phy-core.c#L305

> 
> Signed-off-by: 李哲 <sensor1010@163.com>
> ---
>   drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 700858ff6f7c..6e8b10fda24d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1839,11 +1839,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;
> -	}
> +	phy_power_on(bsp_priv, true);
>   
>   	pm_runtime_get_sync(dev);
>   



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

* Re: [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-05-27  5:43 ` Christophe JAILLET
@ 2025-05-27 13:14   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2025-05-27 13:14 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: 李哲, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, jonas, rmk+kernel, david.wu,
	wens, jan.petrous, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On Tue, May 27, 2025 at 07:43:57AM +0200, Christophe JAILLET wrote:
> Le 26/05/2025 à 18:16, 李哲 a écrit :
> > since the return value of the phy_power_on() function is always 0,
> > checking its return value is redundant.
> 
> Can you elaborate why?
> 
> Looking at  (1], I think that it is obvious that non-0 values can be
> returned.

Wrong phy_power_on(). There is a local scope one within the driver.

	Andrew


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

* [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
@ 2025-05-30 16:20 李哲
  2025-05-30 16:37 ` Russell King (Oracle)
  0 siblings, 1 reply; 6+ messages in thread
From: 李哲 @ 2025-05-30 16:20 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, rmk+kernel, david.wu, jan.petrous,
	detlev.casanova
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	李哲

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.

Signed-off-by: 李哲 <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 700858ff6f7c..f7c32934f8a4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1645,23 +1645,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 phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 {
 	struct regulator *ldo = bsp_priv->regulator;
-	int ret;
 	struct device *dev = &bsp_priv->pdev->dev;
 
 	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,
@@ -1839,11 +1834,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;
-	}
+	phy_power_on(bsp_priv, true);
 
 	pm_runtime_get_sync(dev);
 
-- 
2.17.1



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

* Re: [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on()
  2025-05-30 16:20 [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on() 李哲
@ 2025-05-30 16:37 ` Russell King (Oracle)
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2025-05-30 16:37 UTC (permalink / raw)
  To: 李哲
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, jonas, david.wu, jan.petrous, detlev.casanova,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

On Fri, May 30, 2025 at 09:20:17AM -0700, 李哲 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.
> 
> Signed-off-by: 李哲 <sensor1010@163.com>

Patch looks generally good, nice to see the reverse christmas tree
ordering of local variables resulting from this patch. However, the
subject line needs to be adjusted to meet netdev requirements. Please
see
https://www.kernel.org/doc/html/v5.1/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in
Please wait a minimum of one day before sending an updated version.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Please can you also follow up with a patch to change the function name
from "phy_power_on()" as this may conflict with the PHY subsystems
"int phy_power_on(struct phy *phy);"

"rk_phy_power_set()" would probably be a good alternative name,
especially as when the 2nd argument is false, the function turns the
PHY off.

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!


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

end of thread, other threads:[~2025-05-30 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-30 16:20 [PATCH] net: dwmac-rk: No need to check the return value of the phy_power_on() 李哲
2025-05-30 16:37 ` Russell King (Oracle)
  -- strict thread matches above, loose matches on Subject: below --
2025-05-26 16:16 李哲
2025-05-26 17:05 ` Andrew Lunn
2025-05-27  5:43 ` Christophe JAILLET
2025-05-27 13:14   ` Andrew Lunn

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