Commit 1e1bf14a authored by Russell King's avatar Russell King Committed by David S. Miller

net: phylink: simplify fixed-link case for ksettings_set method

For fixed links, we only allow the current settings, so this should be
a matter of merely rejecting an attempt to change the settings.  If the
settings agree, then there is nothing more we need to do.
Reviewed-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a83c8829
...@@ -1360,22 +1360,31 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, ...@@ -1360,22 +1360,31 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
if (!s) if (!s)
return -EINVAL; return -EINVAL;
/* If we have a fixed link (as specified by firmware), refuse /* If we have a fixed link, refuse to change link parameters.
* to change link parameters. * If the link parameters match, accept them but do nothing.
*/ */
if (pl->cur_link_an_mode == MLO_AN_FIXED && if (pl->cur_link_an_mode == MLO_AN_FIXED) {
(s->speed != pl->link_config.speed || if (s->speed != pl->link_config.speed ||
s->duplex != pl->link_config.duplex)) s->duplex != pl->link_config.duplex)
return -EINVAL; return -EINVAL;
return 0;
}
config.speed = s->speed; config.speed = s->speed;
config.duplex = s->duplex; config.duplex = s->duplex;
break; break;
case AUTONEG_ENABLE: case AUTONEG_ENABLE:
/* If we have a fixed link, refuse to enable autonegotiation */ /* If we have a fixed link, allow autonegotiation (since that
if (pl->cur_link_an_mode == MLO_AN_FIXED) * is our default case) but do not allow the advertisement to
* be changed. If the advertisement matches, simply return.
*/
if (pl->cur_link_an_mode == MLO_AN_FIXED) {
if (!linkmode_equal(config.advertising,
pl->link_config.advertising))
return -EINVAL; return -EINVAL;
return 0;
}
config.speed = SPEED_UNKNOWN; config.speed = SPEED_UNKNOWN;
config.duplex = DUPLEX_UNKNOWN; config.duplex = DUPLEX_UNKNOWN;
...@@ -1385,8 +1394,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, ...@@ -1385,8 +1394,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
return -EINVAL; return -EINVAL;
} }
/* For a fixed link, this isn't able to change any parameters, /* We have ruled out the case with a PHY attached, and the
* which just leaves inband mode. * fixed-link cases. All that is left are in-band links.
*/ */
if (phylink_validate(pl, support, &config)) if (phylink_validate(pl, support, &config))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment