net: dsa: Remove adjust_link paths

Now that we no longer any drivers using PHYLIB's adjust_link callback,
remove all paths that made use of adjust_link as well as the associated
functions.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20240430164816.2400606-3-florian.fainelli@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Florian Fainelli 2024-04-30 09:48:16 -07:00 committed by Jakub Kicinski
parent ad3e1287c6
commit 8a021a863a
3 changed files with 12 additions and 137 deletions

View File

@ -24,8 +24,6 @@
struct dsa_8021q_context; struct dsa_8021q_context;
struct tc_action; struct tc_action;
struct phy_device;
struct phylink_link_state;
#define DSA_TAG_PROTO_NONE_VALUE 0 #define DSA_TAG_PROTO_NONE_VALUE 0
#define DSA_TAG_PROTO_BRCM_VALUE 1 #define DSA_TAG_PROTO_BRCM_VALUE 1
@ -867,11 +865,6 @@ struct dsa_switch_ops {
int (*phy_write)(struct dsa_switch *ds, int port, int (*phy_write)(struct dsa_switch *ds, int port,
int regnum, u16 val); int regnum, u16 val);
/*
* Link state adjustment (called from libphy)
*/
void (*adjust_link)(struct dsa_switch *ds, int port,
struct phy_device *phydev);
/* /*
* PHYLINK integration * PHYLINK integration
*/ */

View File

@ -1511,8 +1511,7 @@ static int dsa_switch_probe(struct dsa_switch *ds)
ds->ops->phylink_mac_config || ds->ops->phylink_mac_config ||
ds->ops->phylink_mac_finish || ds->ops->phylink_mac_finish ||
ds->ops->phylink_mac_link_down || ds->ops->phylink_mac_link_down ||
ds->ops->phylink_mac_link_up || ds->ops->phylink_mac_link_up)
ds->ops->adjust_link)
return -EINVAL; return -EINVAL;
} }

View File

@ -1535,25 +1535,6 @@ void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
cpu_dp->tag_ops = tag_ops; cpu_dp->tag_ops = tag_ops;
} }
static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
{
struct device_node *phy_dn;
struct phy_device *phydev;
phy_dn = of_parse_phandle(dp->dn, "phy-handle", 0);
if (!phy_dn)
return NULL;
phydev = of_phy_find_device(phy_dn);
if (!phydev) {
of_node_put(phy_dn);
return ERR_PTR(-EPROBE_DEFER);
}
of_node_put(phy_dn);
return phydev;
}
static struct phylink_pcs * static struct phylink_pcs *
dsa_port_phylink_mac_select_pcs(struct phylink_config *config, dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface) phy_interface_t interface)
@ -1616,17 +1597,10 @@ static void dsa_port_phylink_mac_link_down(struct phylink_config *config,
phy_interface_t interface) phy_interface_t interface)
{ {
struct dsa_port *dp = dsa_phylink_to_port(config); struct dsa_port *dp = dsa_phylink_to_port(config);
struct phy_device *phydev = NULL;
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
if (dsa_port_is_user(dp)) if (!ds->ops->phylink_mac_link_down)
phydev = dp->user->phydev;
if (!ds->ops->phylink_mac_link_down) {
if (ds->ops->adjust_link && phydev)
ds->ops->adjust_link(ds, dp->index, phydev);
return; return;
}
ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface); ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
} }
@ -1641,11 +1615,8 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
struct dsa_port *dp = dsa_phylink_to_port(config); struct dsa_port *dp = dsa_phylink_to_port(config);
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
if (!ds->ops->phylink_mac_link_up) { if (!ds->ops->phylink_mac_link_up)
if (ds->ops->adjust_link && phydev)
ds->ops->adjust_link(ds, dp->index, phydev);
return; return;
}
ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev, ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
speed, duplex, tx_pause, rx_pause); speed, duplex, tx_pause, rx_pause);
@ -1708,78 +1679,6 @@ void dsa_port_phylink_destroy(struct dsa_port *dp)
dp->pl = NULL; dp->pl = NULL;
} }
static int dsa_shared_port_setup_phy_of(struct dsa_port *dp, bool enable)
{
struct dsa_switch *ds = dp->ds;
struct phy_device *phydev;
int port = dp->index;
int err = 0;
phydev = dsa_port_get_phy_device(dp);
if (!phydev)
return 0;
if (IS_ERR(phydev))
return PTR_ERR(phydev);
if (enable) {
err = genphy_resume(phydev);
if (err < 0)
goto err_put_dev;
err = genphy_read_status(phydev);
if (err < 0)
goto err_put_dev;
} else {
err = genphy_suspend(phydev);
if (err < 0)
goto err_put_dev;
}
if (ds->ops->adjust_link)
ds->ops->adjust_link(ds, port, phydev);
dev_dbg(ds->dev, "enabled port's phy: %s", phydev_name(phydev));
err_put_dev:
put_device(&phydev->mdio.dev);
return err;
}
static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp)
{
struct device_node *dn = dp->dn;
struct dsa_switch *ds = dp->ds;
struct phy_device *phydev;
int port = dp->index;
phy_interface_t mode;
int err;
err = of_phy_register_fixed_link(dn);
if (err) {
dev_err(ds->dev,
"failed to register the fixed PHY of port %d\n",
port);
return err;
}
phydev = of_phy_find_device(dn);
err = of_get_phy_mode(dn, &mode);
if (err)
mode = PHY_INTERFACE_MODE_NA;
phydev->interface = mode;
genphy_read_status(phydev);
if (ds->ops->adjust_link)
ds->ops->adjust_link(ds, port, phydev);
put_device(&phydev->mdio.dev);
return 0;
}
static int dsa_shared_port_phylink_register(struct dsa_port *dp) static int dsa_shared_port_phylink_register(struct dsa_port *dp)
{ {
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
@ -1983,44 +1882,28 @@ int dsa_shared_port_link_register_of(struct dsa_port *dp)
dsa_switches_apply_workarounds)) dsa_switches_apply_workarounds))
return -EINVAL; return -EINVAL;
if (!ds->ops->adjust_link) { if (missing_link_description) {
if (missing_link_description) { dev_warn(ds->dev,
dev_warn(ds->dev, "Skipping phylink registration for %s port %d\n",
"Skipping phylink registration for %s port %d\n", dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); } else {
} else { dsa_shared_port_link_down(dp);
dsa_shared_port_link_down(dp);
return dsa_shared_port_phylink_register(dp); return dsa_shared_port_phylink_register(dp);
}
return 0;
} }
dev_warn(ds->dev, return 0;
"Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n");
if (of_phy_is_fixed_link(dp->dn))
return dsa_shared_port_fixed_link_register_of(dp);
else
return dsa_shared_port_setup_phy_of(dp, true);
} }
void dsa_shared_port_link_unregister_of(struct dsa_port *dp) void dsa_shared_port_link_unregister_of(struct dsa_port *dp)
{ {
struct dsa_switch *ds = dp->ds; if (dp->pl) {
if (!ds->ops->adjust_link && dp->pl) {
rtnl_lock(); rtnl_lock();
phylink_disconnect_phy(dp->pl); phylink_disconnect_phy(dp->pl);
rtnl_unlock(); rtnl_unlock();
dsa_port_phylink_destroy(dp); dsa_port_phylink_destroy(dp);
return; return;
} }
if (of_phy_is_fixed_link(dp->dn))
of_phy_deregister_fixed_link(dp->dn);
else
dsa_shared_port_setup_phy_of(dp, false);
} }
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr, int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr,