From 721d524d8e08fc384da0f14d457fb3f08bd3937e Mon Sep 17 00:00:00 2001 From: Marilene A Garcia Date: Sun, 29 Jun 2025 11:23:26 -0300 Subject: [PATCH] net: eth: altera: fix phy-handle not find issue The function phylink_of_phy_connect() returns 0 in case of success. So, if the phy-handle attribute was found, it will return 0, but phydev will still contain the value NULL, and it will enter the condition if(!phydev) and return an error even in the successful case. --- drivers/net/ethernet/altera/altera_tse_main.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index f4b9e1899024..1323e7cf7f8e 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -936,18 +936,19 @@ static int init_phy(struct net_device *dev) ret = phylink_of_phy_connect(priv->phylink, priv->device->of_node, 0); - if (ret) { - netdev_dbg(dev, "no phy-handle found\n"); - if (!priv->mdio) { - netdev_err(dev, "No phy-handle nor local mdio specified\n"); + if (!ret) + return ret; + + netdev_dbg(dev, "no phy-handle found\n"); + if (!priv->mdio) { + netdev_err(dev, "No phy-handle nor local mdio specified\n"); + return -ENODEV; + } + phydev = connect_local_phy(dev); + if (phydev) { + ret = phylink_connect_phy(priv->phylink, phydev); + if (ret) return -ENODEV; - } - phydev = connect_local_phy(dev); - if (phydev) { - ret = phylink_connect_phy(priv->phylink, phydev); - if (ret) - return -ENODEV; - } } if (!phydev) {