[PATCH net-next 07/12] net: phylink: Factor out phylink_clear_phydev()
From: Maxime Chevallier
Date: Fri Dec 04 2026 - 06:07:47 EST
When disconnecting from a PHY, phylink first clears its internal
references to it, then calls phy_disconnect().
For PHYs that sit behind a mux, we'll only need the first part, as the
mux is the one that attaches and detaches the PHYs from the netdev.
Split that out in phylink_clear_phydev(), in preparation for the phy_mux
support. No functional change intended.
Signed-off-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
---
drivers/net/phy/phylink.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 6f5af388210d..03e255f5ceb1 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2553,14 +2553,7 @@ int phylink_fwnode_phy_connect(struct phylink *pl,
}
EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect);
-/**
- * phylink_disconnect_phy() - disconnect any PHY attached to the phylink
- * instance.
- * @pl: a pointer to a &struct phylink returned from phylink_create()
- *
- * Disconnect any current PHY from the phylink instance described by @pl.
- */
-void phylink_disconnect_phy(struct phylink *pl)
+static struct phy_device *phylink_clear_phydev(struct phylink *pl)
{
struct phy_device *phy;
@@ -2579,10 +2572,25 @@ void phylink_disconnect_phy(struct phylink *pl)
}
mutex_unlock(&pl->phydev_mutex);
- if (phy) {
+ if (phy)
flush_work(&pl->resolve);
+
+ return phy;
+}
+
+/**
+ * phylink_disconnect_phy() - disconnect any PHY attached to the phylink
+ * instance.
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ *
+ * Disconnect any current PHY from the phylink instance described by @pl.
+ */
+void phylink_disconnect_phy(struct phylink *pl)
+{
+ struct phy_device *phy = phylink_clear_phydev(pl);
+
+ if (phy)
phy_disconnect(phy);
- }
}
EXPORT_SYMBOL_GPL(phylink_disconnect_phy);
--
2.56.1