]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
phy: lynx-28g: common lynx_pll_get()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 10 Jun 2026 15:19:41 +0000 (18:19 +0300)
committerVinod Koul <vkoul@kernel.org>
Thu, 11 Jun 2026 07:09:46 +0000 (12:39 +0530)
The logic should be absolutely unchanged in the new 10G Lynx SerDes
driver, so let's move this to phy-fsl-lynx-core.c and update the 28G
Lynx driver to use the common variant.

While at it, update the call site, lynx_28g_lane_remap_pll(), to use the
new data structures, and refactor the NULL pll pointer check (the
current form triggers a checkpatch CHECK).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20260610151952.2141019-6-vladimir.oltean@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/freescale/phy-fsl-lynx-28g.c
drivers/phy/freescale/phy-fsl-lynx-core.c
drivers/phy/freescale/phy-fsl-lynx-core.h

index 570fa74daba0889f97efd9adfabf654506ea9623..5c473d6c233ed985614b4b97aaaebd761ca7f615 100644 (file)
@@ -467,30 +467,6 @@ static const struct lynx_28g_proto_conf lynx_28g_proto_conf[LANE_MODE_MAX] = {
        },
 };
 
-static struct lynx_28g_pll *lynx_28g_pll_get(struct lynx_28g_priv *priv,
-                                            enum lynx_lane_mode mode)
-{
-       struct lynx_28g_pll *pll;
-       int i;
-
-       for (i = 0; i < LYNX_28G_NUM_PLL; i++) {
-               pll = &priv->pll[i];
-
-               if (!pll->enabled)
-                       continue;
-
-               if (test_bit(mode, pll->supported))
-                       return pll;
-       }
-
-       /* no pll supports requested mode, either caller forgot to check
-        * lynx_lane_supports_mode(), or this is a bug.
-        */
-       dev_WARN_ONCE(priv->dev, 1, "no pll for lane mode %s\n",
-                     lynx_lane_mode_str(mode));
-       return NULL;
-}
-
 static void lynx_28g_lane_set_nrate(struct lynx_28g_lane *lane,
                                    struct lynx_28g_pll *pll,
                                    enum lynx_lane_mode lane_mode)
@@ -927,15 +903,15 @@ static int lynx_pcvt_rmw(struct lynx_28g_lane *lane,
        return lynx_pcvt_write(lane, lane_mode, cr, tmp);
 }
 
-static void lynx_28g_lane_remap_pll(struct lynx_28g_lane *lane,
+static void lynx_28g_lane_remap_pll(struct lynx_lane *lane,
                                    enum lynx_lane_mode lane_mode)
 {
-       struct lynx_28g_priv *priv = lane->priv;
-       struct lynx_28g_pll *pll;
+       struct lynx_priv *priv = lane->priv;
+       struct lynx_pll *pll;
 
        /* Switch to the PLL that works with this interface type */
-       pll = lynx_28g_pll_get(priv, lane_mode);
-       if (unlikely(pll == NULL))
+       pll = lynx_pll_get(priv, lane_mode);
+       if (unlikely(!pll))
                return;
 
        lynx_28g_lane_set_pll(lane, pll);
index de45b14d3fb60ae7c3a08960a9a390d5b392084f..5e5bcaa54d09ec3b82fd6c4bd17205a9c5880f6f 100644 (file)
@@ -63,5 +63,29 @@ bool lynx_lane_supports_mode(struct lynx_lane *lane, enum lynx_lane_mode mode)
 }
 EXPORT_SYMBOL_NS_GPL(lynx_lane_supports_mode, "PHY_FSL_LYNX");
 
+struct lynx_pll *lynx_pll_get(struct lynx_priv *priv, enum lynx_lane_mode mode)
+{
+       struct lynx_pll *pll;
+       int i;
+
+       for (i = 0; i < LYNX_NUM_PLL; i++) {
+               pll = &priv->pll[i];
+
+               if (!pll->enabled)
+                       continue;
+
+               if (test_bit(mode, pll->supported))
+                       return pll;
+       }
+
+       /* no pll supports requested mode, either caller forgot to check
+        * lynx_lane_supports_mode(), or this is a bug.
+        */
+       dev_WARN_ONCE(priv->dev, 1, "no pll for lane mode %s\n",
+                     lynx_lane_mode_str(mode));
+       return NULL;
+}
+EXPORT_SYMBOL_NS_GPL(lynx_pll_get, "PHY_FSL_LYNX");
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Freescale Lynx SerDes core functionality");
index f0cb3e80523507dc89b370a03c85604cc1e375b1..b726ff21972b00ad1fd0cb2c5bf885ab7f637c2a 100644 (file)
@@ -85,4 +85,6 @@ const char *lynx_lane_mode_str(enum lynx_lane_mode lane_mode);
 enum lynx_lane_mode phy_interface_to_lane_mode(phy_interface_t intf);
 bool lynx_lane_supports_mode(struct lynx_lane *lane, enum lynx_lane_mode mode);
 
+struct lynx_pll *lynx_pll_get(struct lynx_priv *priv, enum lynx_lane_mode mode);
+
 #endif