Skip to content

Commit 2506f62

Browse files
committed
Merge branch 'net-dsa-adjust_link-removal'
Florian Fainelli says: ==================== net: dsa: adjust_link removal Now that the last in-tree driver (b53) has been converted to PHYLINK, we can get rid of all of code that catered to working with drivers implementing only PHYLIB's adjust_link callback. ==================== Link: https://lore.kernel.org/r/20240430164816.2400606-1-florian.fainelli@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents dcb3fba + 8a021a8 commit 2506f62

3 files changed

Lines changed: 12 additions & 141 deletions

File tree

include/net/dsa.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
struct dsa_8021q_context;
2626
struct tc_action;
27-
struct phy_device;
28-
struct fixed_phy_status;
29-
struct phylink_link_state;
3027

3128
#define DSA_TAG_PROTO_NONE_VALUE 0
3229
#define DSA_TAG_PROTO_BRCM_VALUE 1
@@ -868,14 +865,6 @@ struct dsa_switch_ops {
868865
int (*phy_write)(struct dsa_switch *ds, int port,
869866
int regnum, u16 val);
870867

871-
/*
872-
* Link state adjustment (called from libphy)
873-
*/
874-
void (*adjust_link)(struct dsa_switch *ds, int port,
875-
struct phy_device *phydev);
876-
void (*fixed_link_update)(struct dsa_switch *ds, int port,
877-
struct fixed_phy_status *st);
878-
879868
/*
880869
* PHYLINK integration
881870
*/

net/dsa/dsa.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,7 @@ static int dsa_switch_probe(struct dsa_switch *ds)
15111511
ds->ops->phylink_mac_config ||
15121512
ds->ops->phylink_mac_finish ||
15131513
ds->ops->phylink_mac_link_down ||
1514-
ds->ops->phylink_mac_link_up ||
1515-
ds->ops->adjust_link)
1514+
ds->ops->phylink_mac_link_up)
15161515
return -EINVAL;
15171516
}
15181517

net/dsa/port.c

Lines changed: 11 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,25 +1535,6 @@ void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
15351535
cpu_dp->tag_ops = tag_ops;
15361536
}
15371537

1538-
static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
1539-
{
1540-
struct device_node *phy_dn;
1541-
struct phy_device *phydev;
1542-
1543-
phy_dn = of_parse_phandle(dp->dn, "phy-handle", 0);
1544-
if (!phy_dn)
1545-
return NULL;
1546-
1547-
phydev = of_phy_find_device(phy_dn);
1548-
if (!phydev) {
1549-
of_node_put(phy_dn);
1550-
return ERR_PTR(-EPROBE_DEFER);
1551-
}
1552-
1553-
of_node_put(phy_dn);
1554-
return phydev;
1555-
}
1556-
15571538
static struct phylink_pcs *
15581539
dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
15591540
phy_interface_t interface)
@@ -1616,17 +1597,10 @@ static void dsa_port_phylink_mac_link_down(struct phylink_config *config,
16161597
phy_interface_t interface)
16171598
{
16181599
struct dsa_port *dp = dsa_phylink_to_port(config);
1619-
struct phy_device *phydev = NULL;
16201600
struct dsa_switch *ds = dp->ds;
16211601

1622-
if (dsa_port_is_user(dp))
1623-
phydev = dp->user->phydev;
1624-
1625-
if (!ds->ops->phylink_mac_link_down) {
1626-
if (ds->ops->adjust_link && phydev)
1627-
ds->ops->adjust_link(ds, dp->index, phydev);
1602+
if (!ds->ops->phylink_mac_link_down)
16281603
return;
1629-
}
16301604

16311605
ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
16321606
}
@@ -1641,11 +1615,8 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
16411615
struct dsa_port *dp = dsa_phylink_to_port(config);
16421616
struct dsa_switch *ds = dp->ds;
16431617

1644-
if (!ds->ops->phylink_mac_link_up) {
1645-
if (ds->ops->adjust_link && phydev)
1646-
ds->ops->adjust_link(ds, dp->index, phydev);
1618+
if (!ds->ops->phylink_mac_link_up)
16471619
return;
1648-
}
16491620

16501621
ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
16511622
speed, duplex, tx_pause, rx_pause);
@@ -1708,78 +1679,6 @@ void dsa_port_phylink_destroy(struct dsa_port *dp)
17081679
dp->pl = NULL;
17091680
}
17101681

1711-
static int dsa_shared_port_setup_phy_of(struct dsa_port *dp, bool enable)
1712-
{
1713-
struct dsa_switch *ds = dp->ds;
1714-
struct phy_device *phydev;
1715-
int port = dp->index;
1716-
int err = 0;
1717-
1718-
phydev = dsa_port_get_phy_device(dp);
1719-
if (!phydev)
1720-
return 0;
1721-
1722-
if (IS_ERR(phydev))
1723-
return PTR_ERR(phydev);
1724-
1725-
if (enable) {
1726-
err = genphy_resume(phydev);
1727-
if (err < 0)
1728-
goto err_put_dev;
1729-
1730-
err = genphy_read_status(phydev);
1731-
if (err < 0)
1732-
goto err_put_dev;
1733-
} else {
1734-
err = genphy_suspend(phydev);
1735-
if (err < 0)
1736-
goto err_put_dev;
1737-
}
1738-
1739-
if (ds->ops->adjust_link)
1740-
ds->ops->adjust_link(ds, port, phydev);
1741-
1742-
dev_dbg(ds->dev, "enabled port's phy: %s", phydev_name(phydev));
1743-
1744-
err_put_dev:
1745-
put_device(&phydev->mdio.dev);
1746-
return err;
1747-
}
1748-
1749-
static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp)
1750-
{
1751-
struct device_node *dn = dp->dn;
1752-
struct dsa_switch *ds = dp->ds;
1753-
struct phy_device *phydev;
1754-
int port = dp->index;
1755-
phy_interface_t mode;
1756-
int err;
1757-
1758-
err = of_phy_register_fixed_link(dn);
1759-
if (err) {
1760-
dev_err(ds->dev,
1761-
"failed to register the fixed PHY of port %d\n",
1762-
port);
1763-
return err;
1764-
}
1765-
1766-
phydev = of_phy_find_device(dn);
1767-
1768-
err = of_get_phy_mode(dn, &mode);
1769-
if (err)
1770-
mode = PHY_INTERFACE_MODE_NA;
1771-
phydev->interface = mode;
1772-
1773-
genphy_read_status(phydev);
1774-
1775-
if (ds->ops->adjust_link)
1776-
ds->ops->adjust_link(ds, port, phydev);
1777-
1778-
put_device(&phydev->mdio.dev);
1779-
1780-
return 0;
1781-
}
1782-
17831682
static int dsa_shared_port_phylink_register(struct dsa_port *dp)
17841683
{
17851684
struct dsa_switch *ds = dp->ds;
@@ -1983,44 +1882,28 @@ int dsa_shared_port_link_register_of(struct dsa_port *dp)
19831882
dsa_switches_apply_workarounds))
19841883
return -EINVAL;
19851884

1986-
if (!ds->ops->adjust_link) {
1987-
if (missing_link_description) {
1988-
dev_warn(ds->dev,
1989-
"Skipping phylink registration for %s port %d\n",
1990-
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
1991-
} else {
1992-
dsa_shared_port_link_down(dp);
1885+
if (missing_link_description) {
1886+
dev_warn(ds->dev,
1887+
"Skipping phylink registration for %s port %d\n",
1888+
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
1889+
} else {
1890+
dsa_shared_port_link_down(dp);
19931891

1994-
return dsa_shared_port_phylink_register(dp);
1995-
}
1996-
return 0;
1892+
return dsa_shared_port_phylink_register(dp);
19971893
}
19981894

1999-
dev_warn(ds->dev,
2000-
"Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n");
2001-
2002-
if (of_phy_is_fixed_link(dp->dn))
2003-
return dsa_shared_port_fixed_link_register_of(dp);
2004-
else
2005-
return dsa_shared_port_setup_phy_of(dp, true);
1895+
return 0;
20061896
}
20071897

20081898
void dsa_shared_port_link_unregister_of(struct dsa_port *dp)
20091899
{
2010-
struct dsa_switch *ds = dp->ds;
2011-
2012-
if (!ds->ops->adjust_link && dp->pl) {
1900+
if (dp->pl) {
20131901
rtnl_lock();
20141902
phylink_disconnect_phy(dp->pl);
20151903
rtnl_unlock();
20161904
dsa_port_phylink_destroy(dp);
20171905
return;
20181906
}
2019-
2020-
if (of_phy_is_fixed_link(dp->dn))
2021-
of_phy_deregister_fixed_link(dp->dn);
2022-
else
2023-
dsa_shared_port_setup_phy_of(dp, false);
20241907
}
20251908

20261909
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr,

0 commit comments

Comments
 (0)