source of highlighter
plain | download
    1 From 4e664c09798d999a7b92bd034be3a59aaa043a80 Mon Sep 17 00:00:00 2001
    2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
    3 Date: Fri, 26 Nov 2021 16:47:43 +0000
    4 Subject: [PATCH net-next 01/12] net: phylink: add ability to validate a set of
    5  interface modes
    6 MIME-Version: 1.0
    7 Content-Type: text/plain; charset=UTF-8
    8 Content-Transfer-Encoding: 8bit
    9 
   10 Rather than having the ability to validate all supported interface
   11 modes or a single interface mode, introduce the ability to validate
   12 a subset of supported modes.
   13 
   14 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
   15 [ rebased on current net-next ]
   16 Signed-off-by: Marek BehĂșn <kabel@kernel.org>
   17 ---
   18  drivers/net/phy/phylink.c | 17 ++++++++++-------
   19  1 file changed, 10 insertions(+), 7 deletions(-)
   20 
   21 diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
   22 index d0af026c9afa..2cf388fad1be 100644
   23 --- a/drivers/net/phy/phylink.c
   24 +++ b/drivers/net/phy/phylink.c
   25 @@ -637,8 +637,9 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
   26         return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
   27  }
   28  
   29 -static int phylink_validate_any(struct phylink *pl, unsigned long *supported,
   30 -                               struct phylink_link_state *state)
   31 +static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
   32 +                                struct phylink_link_state *state,
   33 +                                const unsigned long *interfaces)
   34  {
   35         __ETHTOOL_DECLARE_LINK_MODE_MASK(all_adv) = { 0, };
   36         __ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, };
   37 @@ -647,7 +648,7 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported,
   38         int intf;
   39  
   40         for (intf = 0; intf < PHY_INTERFACE_MODE_MAX; intf++) {
   41 -               if (test_bit(intf, pl->config->supported_interfaces)) {
   42 +               if (test_bit(intf, interfaces)) {
   43                         linkmode_copy(s, supported);
   44  
   45                         t = *state;
   46 @@ -668,12 +669,14 @@ static int phylink_validate_any(struct phylink *pl, unsigned long *supported,
   47  static int phylink_validate(struct phylink *pl, unsigned long *supported,
   48                             struct phylink_link_state *state)
   49  {
   50 -       if (!phy_interface_empty(pl->config->supported_interfaces)) {
   51 +       const unsigned long *interfaces = pl->config->supported_interfaces;
   52 +
   53 +       if (!phy_interface_empty(interfaces)) {
   54                 if (state->interface == PHY_INTERFACE_MODE_NA)
   55 -                       return phylink_validate_any(pl, supported, state);
   56 +                       return phylink_validate_mask(pl, supported, state,
   57 +                                                    interfaces);
   58  
   59 -               if (!test_bit(state->interface,
   60 -                             pl->config->supported_interfaces))
   61 +               if (!test_bit(state->interface, interfaces))
   62                         return -EINVAL;
   63         }
   64  
   65 -- 
   66 2.35.1
   67