Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+12 -141
-11
include/net/dsa.h
··· 24 24 25 25 struct dsa_8021q_context; 26 26 struct tc_action; 27 - struct phy_device; 28 - struct fixed_phy_status; 29 - struct phylink_link_state; 30 27 31 28 #define DSA_TAG_PROTO_NONE_VALUE 0 32 29 #define DSA_TAG_PROTO_BRCM_VALUE 1 ··· 864 867 int (*phy_read)(struct dsa_switch *ds, int port, int regnum); 865 868 int (*phy_write)(struct dsa_switch *ds, int port, 866 869 int regnum, u16 val); 867 - 868 - /* 869 - * Link state adjustment (called from libphy) 870 - */ 871 - void (*adjust_link)(struct dsa_switch *ds, int port, 872 - struct phy_device *phydev); 873 - void (*fixed_link_update)(struct dsa_switch *ds, int port, 874 - struct fixed_phy_status *st); 875 870 876 871 /* 877 872 * PHYLINK integration
+1 -2
net/dsa/dsa.c
··· 1511 1511 ds->ops->phylink_mac_config || 1512 1512 ds->ops->phylink_mac_finish || 1513 1513 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) 1516 1515 return -EINVAL; 1517 1516 } 1518 1517
+11 -128
net/dsa/port.c
··· 1535 1535 cpu_dp->tag_ops = tag_ops; 1536 1536 } 1537 1537 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 - 1557 1538 static struct phylink_pcs * 1558 1539 dsa_port_phylink_mac_select_pcs(struct phylink_config *config, 1559 1540 phy_interface_t interface) ··· 1597 1616 phy_interface_t interface) 1598 1617 { 1599 1618 struct dsa_port *dp = dsa_phylink_to_port(config); 1600 - struct phy_device *phydev = NULL; 1601 1619 struct dsa_switch *ds = dp->ds; 1602 1620 1603 - if (dsa_port_is_user(dp)) 1604 - phydev = dp->user->phydev; 1605 - 1606 - if (!ds->ops->phylink_mac_link_down) { 1607 - if (ds->ops->adjust_link && phydev) 1608 - ds->ops->adjust_link(ds, dp->index, phydev); 1621 + if (!ds->ops->phylink_mac_link_down) 1609 1622 return; 1610 - } 1611 1623 1612 1624 ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface); 1613 1625 } ··· 1615 1641 struct dsa_port *dp = dsa_phylink_to_port(config); 1616 1642 struct dsa_switch *ds = dp->ds; 1617 1643 1618 - if (!ds->ops->phylink_mac_link_up) { 1619 - if (ds->ops->adjust_link && phydev) 1620 - ds->ops->adjust_link(ds, dp->index, phydev); 1644 + if (!ds->ops->phylink_mac_link_up) 1621 1645 return; 1622 - } 1623 1646 1624 1647 ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev, 1625 1648 speed, duplex, tx_pause, rx_pause); ··· 1677 1706 { 1678 1707 phylink_destroy(dp->pl); 1679 1708 dp->pl = NULL; 1680 - } 1681 - 1682 - static int dsa_shared_port_setup_phy_of(struct dsa_port *dp, bool enable) 1683 - { 1684 - struct dsa_switch *ds = dp->ds; 1685 - struct phy_device *phydev; 1686 - int port = dp->index; 1687 - int err = 0; 1688 - 1689 - phydev = dsa_port_get_phy_device(dp); 1690 - if (!phydev) 1691 - return 0; 1692 - 1693 - if (IS_ERR(phydev)) 1694 - return PTR_ERR(phydev); 1695 - 1696 - if (enable) { 1697 - err = genphy_resume(phydev); 1698 - if (err < 0) 1699 - goto err_put_dev; 1700 - 1701 - err = genphy_read_status(phydev); 1702 - if (err < 0) 1703 - goto err_put_dev; 1704 - } else { 1705 - err = genphy_suspend(phydev); 1706 - if (err < 0) 1707 - goto err_put_dev; 1708 - } 1709 - 1710 - if (ds->ops->adjust_link) 1711 - ds->ops->adjust_link(ds, port, phydev); 1712 - 1713 - dev_dbg(ds->dev, "enabled port's phy: %s", phydev_name(phydev)); 1714 - 1715 - err_put_dev: 1716 - put_device(&phydev->mdio.dev); 1717 - return err; 1718 - } 1719 - 1720 - static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp) 1721 - { 1722 - struct device_node *dn = dp->dn; 1723 - struct dsa_switch *ds = dp->ds; 1724 - struct phy_device *phydev; 1725 - int port = dp->index; 1726 - phy_interface_t mode; 1727 - int err; 1728 - 1729 - err = of_phy_register_fixed_link(dn); 1730 - if (err) { 1731 - dev_err(ds->dev, 1732 - "failed to register the fixed PHY of port %d\n", 1733 - port); 1734 - return err; 1735 - } 1736 - 1737 - phydev = of_phy_find_device(dn); 1738 - 1739 - err = of_get_phy_mode(dn, &mode); 1740 - if (err) 1741 - mode = PHY_INTERFACE_MODE_NA; 1742 - phydev->interface = mode; 1743 - 1744 - genphy_read_status(phydev); 1745 - 1746 - if (ds->ops->adjust_link) 1747 - ds->ops->adjust_link(ds, port, phydev); 1748 - 1749 - put_device(&phydev->mdio.dev); 1750 - 1751 - return 0; 1752 1709 } 1753 1710 1754 1711 static int dsa_shared_port_phylink_register(struct dsa_port *dp) ··· 1882 1983 dsa_switches_apply_workarounds)) 1883 1984 return -EINVAL; 1884 1985 1885 - if (!ds->ops->adjust_link) { 1886 - if (missing_link_description) { 1887 - dev_warn(ds->dev, 1888 - "Skipping phylink registration for %s port %d\n", 1889 - dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); 1890 - } else { 1891 - dsa_shared_port_link_down(dp); 1986 + if (missing_link_description) { 1987 + dev_warn(ds->dev, 1988 + "Skipping phylink registration for %s port %d\n", 1989 + dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); 1990 + } else { 1991 + dsa_shared_port_link_down(dp); 1892 1992 1893 - return dsa_shared_port_phylink_register(dp); 1894 - } 1895 - return 0; 1993 + return dsa_shared_port_phylink_register(dp); 1896 1994 } 1897 1995 1898 - dev_warn(ds->dev, 1899 - "Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n"); 1900 - 1901 - if (of_phy_is_fixed_link(dp->dn)) 1902 - return dsa_shared_port_fixed_link_register_of(dp); 1903 - else 1904 - return dsa_shared_port_setup_phy_of(dp, true); 1996 + return 0; 1905 1997 } 1906 1998 1907 1999 void dsa_shared_port_link_unregister_of(struct dsa_port *dp) 1908 2000 { 1909 - struct dsa_switch *ds = dp->ds; 1910 - 1911 - if (!ds->ops->adjust_link && dp->pl) { 2001 + if (dp->pl) { 1912 2002 rtnl_lock(); 1913 2003 phylink_disconnect_phy(dp->pl); 1914 2004 rtnl_unlock(); 1915 2005 dsa_port_phylink_destroy(dp); 1916 2006 return; 1917 2007 } 1918 - 1919 - if (of_phy_is_fixed_link(dp->dn)) 1920 - of_phy_deregister_fixed_link(dp->dn); 1921 - else 1922 - dsa_shared_port_setup_phy_of(dp, false); 1923 2008 } 1924 2009 1925 2010 int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr,