stmmac: fix check for phydev being open
Subsystems (5)
PATCH v2 1/1 stmmac: fix check for phydev being open
Current implementation via IS_ERR(phydev) may make no sense because of_phy_attach() returns NULL on failure instead of error value.
Still for checking result of phy_connect() IS_ERR() is useful.
To address both situations we use combined IS_ERR_OR_NULL() check.
---
Changes compared to v1:
* Use IS_ERR_OR_NULL() instead of discrete checks for null and err
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -837,7 +837,7 @@ static int stmmac_init_phy(struct net_device *dev) interface); } -if (IS_ERR (phydev)) { +if (IS_ERR_OR_NULL (phydev)) {pr_err ("%s: Could not attach to PHY\n" , dev->name);return PTR_ERR (phydev); }
Signature · 1 line
2.4.3
Quoted 26 lines · Alexey Brodkin
Current implementation via
IS_ERR(phydev)may make no sense becauseof_phy_attach()returns NULL on failure instead of error value.Still for checking result of
phy_connect()IS_ERR()is useful.To address both situations we use combined
IS_ERR_OR_NULL()check.Cc Giuseppe Cavallaro <[email protected]>Cc David Miller <[email protected]>Cc Sergei Shtylyov <[email protected]>Signed-off-by Alexey Brodkin <[email protected]>---
Changes compared to v1:
* UseIS_ERR_OR_NULL()instead of discrete checks for null and errdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_phy(struct net_device *dev) · line 842
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -837,7 +837,7 @@ static int stmmac_init_phy(struct net_device *dev) interface); } -if (IS_ERR (phydev)) { +if (IS_ERR_OR_NULL (phydev)) {pr_err ("%s: Could not attach to PHY\n" , dev->name);return PTR_ERR (phydev);
Hm, in case of phydev == NULL, you're going to return 0 here... is that
what you want?
MBR, Sergei
Hi Sergei,
Quoted 31 lines · Sergei Shtylyov
Quoted 29 lines · Alexey Brodkin
Current implementation via
IS_ERR(phydev)may make no sense becauseof_phy_attach()returns NULL on failure instead of error value.Still for checking result of
phy_connect()IS_ERR()is useful.To address both situations we use combined
IS_ERR_OR_NULL()check.Cc Giuseppe Cavallaro <[email protected]>Cc David Miller <[email protected]>Cc Sergei Shtylyov <[email protected]>Signed-off-by Alexey Brodkin <[email protected]>---
Changes compared to v1:
* UseIS_ERR_OR_NULL()instead of discrete checks for null and errdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-- 1 file changed, 1 insertion(+-), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +-+-+- b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c@@ -837,7 +-837,7 @@ static int
stmmac_init_phy(struct net_device *dev)
interface);
}
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_phy(struct net_device *dev) · line 842
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1-if (IS_ERR (phydev)) { +- if (IS_ERR_OR_NULL(phydev)) {pr_err ("%s: Could not attach to PHY\n" , dev->name);return PTR_ERR (phydev);Hm, in case of phydev == NULL, you're going to return 0 here... is thatwhat you want?
Ah, right.
So then the question would be what's a proper error code for !phydev:-ENOENT or -ENODEV?
-Alexey
Quoted 2 lines · Alexey Brodkin
Current implementation via
IS_ERR(phydev)may make no sense becauseof_phy_attach()returns NULL on failure instead of error value.
Not of_phy_connect()?
Quoted 10 lines
Still for checking result of
phy_connect()IS_ERR()is useful.To address both situations we use combined
IS_ERR_OR_NULL()check.Cc Giuseppe Cavallaro <[email protected]>Cc David Miller <[email protected]>Cc Sergei Shtylyov <[email protected]>Signed-off-by Alexey Brodkin <[email protected]>
MBR, Sergei
Hi Sergei,
Quoted 6 lines · Sergei Shtylyov
Quoted 2 lines · Alexey Brodkin
Current implementation via
IS_ERR(phydev)may make no sense becauseof_phy_attach()returns NULL on failure instead of error value.Not
of_phy_connect()?
I already noticed this misspelling - it came from my exploration of what happens inside of_phy_connect(). So sort of braindump.
I will fix in v3 re-spin.
-Alexey