diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index a03879a27b04..253bf6d66280 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1299,24 +1299,17 @@ static int ftgmac100_init_all(struct ftgmac100 *priv, bool ignore_alloc_err) return err; } -static void ftgmac100_reset(struct ftgmac100 *priv) +static void ftgmac100_reset_unlocked(struct ftgmac100 *priv) { struct net_device *netdev = priv->netdev; int err; netdev_dbg(netdev, "Resetting NIC...\n"); - /* Lock the world */ - rtnl_lock(); - if (netdev->phydev) - mutex_lock(&netdev->phydev->lock); - if (priv->mii_bus) - mutex_lock(&priv->mii_bus->mdio_lock); - /* Check if the interface is still up */ if (!netif_running(netdev)) - goto bail; + return; /* Stop the network stack */ netif_trans_update(netdev); @@ -1338,7 +1331,19 @@ static void ftgmac100_reset(struct ftgmac100 *priv) ftgmac100_init_all(priv, true); netdev_dbg(netdev, "Reset done !\n"); - bail: +} + +static void ftgmac100_reset(struct ftgmac100 *priv) +{ + struct net_device *netdev = priv->netdev; + + rtnl_lock(); + /* Lock the world */ + if (netdev->phydev) + mutex_lock(&netdev->phydev->lock); + if (priv->mii_bus) + mutex_lock(&priv->mii_bus->mdio_lock); + ftgmac100_reset_unlocked(priv); if (priv->mii_bus) mutex_unlock(&priv->mii_bus->mdio_lock); if (netdev->phydev) @@ -1405,14 +1410,7 @@ static void ftgmac100_adjust_link(struct net_device *netdev) /* Release phy lock to allow ftgmac100_reset to aquire it, keeping lock * order consistent to prevent dead lock. */ - if (netdev->phydev) - mutex_unlock(&netdev->phydev->lock); - - ftgmac100_reset(priv); - - if (netdev->phydev) - mutex_lock(&netdev->phydev->lock); - + ftgmac100_reset_unlocked(priv); } static int ftgmac100_mii_probe(struct net_device *netdev)