Commit 1645f44d authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by David S. Miller

net: phylink: add ability to validate a set of interface modes

Rather than having the ability to validate all supported interface
modes or a single interface mode, introduce the ability to validate
a subset of supported modes.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
[ rebased on current net-next ]
Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3735264d
...@@ -637,8 +637,9 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl, ...@@ -637,8 +637,9 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
return phylink_is_empty_linkmode(supported) ? -EINVAL : 0; return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
} }
static int phylink_validate_any(struct phylink *pl, unsigned long *supported, static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
struct phylink_link_state *state) struct phylink_link_state *state,
const unsigned long *interfaces)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(all_adv) = { 0, }; __ETHTOOL_DECLARE_LINK_MODE_MASK(all_adv) = { 0, };
__ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, }; __ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, };
...@@ -647,7 +648,7 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported, ...@@ -647,7 +648,7 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported,
int intf; int intf;
for (intf = 0; intf < PHY_INTERFACE_MODE_MAX; intf++) { for (intf = 0; intf < PHY_INTERFACE_MODE_MAX; intf++) {
if (test_bit(intf, pl->config->supported_interfaces)) { if (test_bit(intf, interfaces)) {
linkmode_copy(s, supported); linkmode_copy(s, supported);
t = *state; t = *state;
...@@ -668,12 +669,14 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported, ...@@ -668,12 +669,14 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported,
static int phylink_validate(struct phylink *pl, unsigned long *supported, static int phylink_validate(struct phylink *pl, unsigned long *supported,
struct phylink_link_state *state) struct phylink_link_state *state)
{ {
if (!phy_interface_empty(pl->config->supported_interfaces)) { const unsigned long *interfaces = pl->config->supported_interfaces;
if (!phy_interface_empty(interfaces)) {
if (state->interface == PHY_INTERFACE_MODE_NA) if (state->interface == PHY_INTERFACE_MODE_NA)
return phylink_validate_any(pl, supported, state); return phylink_validate_mask(pl, supported, state,
interfaces);
if (!test_bit(state->interface, if (!test_bit(state->interface, interfaces))
pl->config->supported_interfaces))
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