[PATCH net-next 10/15] net: pcs: xpcs: introduce xpcs_create_pcs_fwnode()

Vladimir Oltean
2025-11-18T19:06:08Z

Introduce a wrapper over xpcs_create_fwnode() that doesn't return the
specific dw_xpcs pointer type, but the generic phylink_pcs pointer type.
For example, the NXP SJA1105 driver might use this if it has a
pcs-handle - it is already a user of xpcs_create_pcs_mdiodev().

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/pcs/pcs-xpcs.c | 12 ++++++++++++
include/linux/pcs/pcs-xpcs.h | 1 +
2 files changed, 13 insertions(+)

diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 3d1bd5aac093..8f7c43a066c8 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1591,6 +1591,18 @@ struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode)
}
EXPORT_SYMBOL_GPL(xpcs_create_fwnode);

+struct phylink_pcs *xpcs_create_pcs_fwnode(struct fwnode_handle *fwnode)
+{
+ struct dw_xpcs *xpcs;
+
+ xpcs = xpcs_create_fwnode(fwnode);
+ if (IS_ERR(xpcs))
+ return ERR_CAST(xpcs);
+
+ return &xpcs->pcs;
+}
+EXPORT_SYMBOL_GPL(xpcs_create_pcs_fwnode);
+
void xpcs_destroy(struct dw_xpcs *xpcs)
{
if (!xpcs)
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index e40f554ff717..1fcbcd419ede 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -56,6 +56,7 @@ struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode);
void xpcs_destroy(struct dw_xpcs *xpcs);

struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr);
+struct phylink_pcs *xpcs_create_pcs_fwnode(struct fwnode_handle *fwnode);
void xpcs_destroy_pcs(struct phylink_pcs *pcs);

#endif /* __LINUX_PCS_XPCS_H */
--
2.34.1