[PATCH net-next 03/12] net: phy: Don't create the sysfs links for PHYs behind a mux

Maxime Chevallier maxime.chevallier at bootlin.com
Fri Dec 4 03:06:12 PST 2026


The phy_mux framework allows attaching multiple PHYs to the same netdev,
one of them being actively used at any given time.

Attached phys create sysfs links in the netdev entry, pointing to the
PHY. We can't have two of them (otherwise they'd overwrite one another),
so let's just not create these. PHYs are still visible through the
phy_link_topology API.

Signed-off-by: Maxime Chevallier <maxime.chevallier at bootlin.com>
---
 drivers/net/phy/phy_device.c | 3 ++-
 include/linux/phy.h          | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 60440b62e6c7..9630578a6a5c 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2019,7 +2019,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	 */
 	phydev->sysfs_links = false;
 
-	phy_sysfs_create_links(phydev);
+	if (!phydev->mux_port)
+		phy_sysfs_create_links(phydev);
 
 	if (!phydev->attached_dev) {
 		err = sysfs_create_file(&phydev->mdio.dev.kobj,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f1b1ad1dd82f..a6cd2fc642ad 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -328,6 +328,7 @@ static inline long rgmii_clock(int speed)
 struct device;
 struct kernel_hwtstamp_config;
 struct phylink;
+struct phy_mux_port;
 struct phy_port;
 struct sfp_bus;
 struct sfp_upstream_ops;
@@ -618,6 +619,7 @@ struct phy_oatc14_sqi_capability {
  * @sfp_cage_port: The phy_port connected to the downstream SFP cage
  * @mod_port: phy_port representing the SFP module, if it is phy-less
  * @upstream_port: phy_port this PHY's MII attaches to, if any
+ * @mux_port: The mux port this PHY sits behind, if any
  * @attached_dev: The attached enet driver's device instance ptr
  * @adjust_link: Callback for the enet controller to respond to changes: in the
  *               link state.
@@ -814,6 +816,7 @@ struct phy_device {
 	struct phy_port *sfp_cage_port;
 	struct phy_port *mod_port;
 	struct phy_port *upstream_port;
+	struct phy_mux_port *mux_port;
 	struct phylink *phylink;
 	struct net_device *attached_dev;
 	struct mii_timestamper *mii_ts;
-- 
2.56.1




More information about the linux-arm-kernel mailing list