net: phylink: only call mac_config() during resolve when link is up
authorRussell King <rmk+kernel@armlinux.org.uk>
Mon, 11 Feb 2019 11:46:01 +0000 (11:46 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Feb 2019 17:22:20 +0000 (12:22 -0500)
There's little point calling mac_config() when the link is down.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phylink.c

index 2e21ce42e38861159cdd9ea42644b5885d8bae1d..a148866cbb14bd7e98826947a20a98b2a019f3b9 100644 (file)
@@ -302,6 +302,13 @@ static void phylink_mac_config(struct phylink *pl,
        pl->ops->mac_config(pl->netdev, pl->link_an_mode, state);
 }
 
+static void phylink_mac_config_up(struct phylink *pl,
+                                 const struct phylink_link_state *state)
+{
+       if (state->link)
+               phylink_mac_config(pl, state);
+}
+
 static void phylink_mac_an_restart(struct phylink *pl)
 {
        if (pl->link_config.an_enabled &&
@@ -401,12 +408,12 @@ static void phylink_resolve(struct work_struct *w)
                case MLO_AN_PHY:
                        link_state = pl->phy_state;
                        phylink_resolve_flow(pl, &link_state);
-                       phylink_mac_config(pl, &link_state);
+                       phylink_mac_config_up(pl, &link_state);
                        break;
 
                case MLO_AN_FIXED:
                        phylink_get_fixed_state(pl, &link_state);
-                       phylink_mac_config(pl, &link_state);
+                       phylink_mac_config_up(pl, &link_state);
                        break;
 
                case MLO_AN_INBAND: