realtek: dsa: handle error returned by PCS
authorJonas Jelonek <[email protected]>
Mon, 27 Oct 2025 18:46:08 +0000 (18:46 +0000)
committerRobert Marko <[email protected]>
Sun, 2 Nov 2025 15:32:09 +0000 (16:32 +0100)
Check for and handle an error which may be returned by rtpcs_create in
various cases.

Signed-off-by: Jonas Jelonek <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20577
Signed-off-by: Robert Marko <[email protected]>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c

index a073a1a5d245b6d642c4b29cb08c5dbdb6781cfa..190e495287c59879e914bd610825d482b9778338 100644 (file)
@@ -335,8 +335,6 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
                        continue;
 
                pcs_node = of_parse_phandle(dn, "pcs-handle", 0);
-               priv->pcs[pn] = rtpcs_create(priv->dev, pcs_node, pn);
-
                phy_node = of_parse_phandle(dn, "phy-handle", 0);
                if (!phy_node) {
                        if (pn != priv->cpu_port)
@@ -344,6 +342,14 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
                        continue;
                }
 
+               priv->pcs[pn] = rtpcs_create(priv->dev, pcs_node, pn);
+               if (IS_ERR(priv->pcs[pn])) {
+                       dev_err(priv->dev, "port %u failed to create PCS instance: %ld\n",
+                               pn, PTR_ERR(priv->pcs[pn]));
+                       priv->pcs[pn] = NULL;
+                       continue;
+               }
+
                /*
                 * TODO: phylink_pcs was completely converted to the standalone PCS driver - see
                 * rtpcs_create(). Nevertheless the DSA driver still relies on the info about the