Skip to contentSkip to conversation

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

PATCH In review 李哲 3 participants 4 messages May 26, 2025 – May 27, 2025

Subsystems (5)
lore
Share & tools
lore

李哲

author
#0 lore raw

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

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

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -5
index 700858ff6f7c..6e8b10fda24d 100644
@@ -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);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · 李哲

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

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -0
index 700858ff6f7c..6e8b10fda24d 100644

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

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -5
@@ -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

#2 lore raw
In reply to 李哲

Le 26/05/2025 à 18:16, 李哲 a écrit :

Quoted 2 lines

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

Quoted 23 lines
---
  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +1 -5
index 700858ff6f7c..6e8b10fda24d 100644
@@ -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);
 
#3 lore raw
Quoted 8 lines · Christophe JAILLET

Le 26/05/2025 à 18:16, 李哲 a écrit :

Quoted 2 lines

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