• Vladimir Oltean's avatar
    net: dsa: avoid dsa_port_link_{,un}register_of() calls with platform data · da2c398e
    Vladimir Oltean authored
    dsa_port_link_register_of() and dsa_port_link_unregister_of() are not
    written with the fact in mind that they can be called with a dp->dn that
    is NULL (as evidenced even by the _of suffix in their name), but this is
    exactly what happens.
    
    How this behaves will differ depending on whether the backing driver
    implements ->adjust_link() or not.
    
    If it doesn't, the "if (of_phy_is_fixed_link(dp->dn) || phy_np)"
    condition will return false, and dsa_port_link_register_of() will do
    nothing and return 0.
    
    If the driver does implement ->adjust_link(), the
    "if (of_phy_is_fixed_link(dp->dn))" condition will return false
    (dp->dn is NULL) and we will call dsa_port_setup_phy_of(). This will
    call dsa_port_get_phy_device(), which will also return NULL, and we will
    also do nothing and return 0.
    
    It is hard to maintain this code and make future changes to it in this
    state, so just suppress calls to these 2 functions if dp->dn is NULL.
    The only functional effect is that if the driver does implement
    ->adjust_link(), we'll stop printing this to the console:
    
    Using legacy PHYLIB callbacks. Please migrate to PHYLINK!
    
    but instead we'll always print:
    
    [    8.539848] dsa-loop fixed-0:1f: skipping link registration for CPU port 5
    
    This is for the better anyway, since "using legacy phylib callbacks"
    was misleading information - we weren't issuing _any_ callbacks due to
    dsa_port_get_phy_device() returning NULL.
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    da2c398e
dsa2.c 40.6 KB