From nobody Mon Feb 9 00:54:18 2026 Received: from TWMBX01.aspeed.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6DA35E548; Wed, 4 Feb 2026 05:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770182803; cv=none; b=q7CVWZSnFokWmQwnenBVl89hegPbTlSggBS3lCwIaCwXIFAXj5hxwk3jQeasNT7qMP6SCEFKA+z7471Zpob/U21MSmjiOX2nn+0LM1Zr9Uv1F6a/lJ2o2kpWy7m2u8RHLCTYVC3Ubg0DF/4LenI5rmfqUfYtGCWglqLRz7FjRSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770182803; c=relaxed/simple; bh=J3dX5F3ZiK1SpSJ+nrfRy7k8oQkQE4tDxcff2zzXXEc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=MCQ4J1tGnhyIpyWKzQMkFH14x6CCW/eGNmMUprPH/ZwL3TQ21Hu5X49OntcCQaJiIQrCRI5gr9mv57Hq/kNofHIopSuQH9/hWH49GXSjdhT3symHpxXHetr3/7HsHHSggSuQy51GRax6x+xDl7hMuO1ktPOiCnPQEfrkqwaR/rY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass smtp.mailfrom=aspeedtech.com; arc=none smtp.client-ip=211.20.114.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aspeedtech.com Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 4 Feb 2026 13:26:31 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 4 Feb 2026 13:26:31 +0800 From: Jacky Chou Date: Wed, 4 Feb 2026 13:26:34 +0800 Subject: [PATCH net-next v4 08/15] net: ftgmac100: Move NCSI probe code into a helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260204-ftgmac-cleanup-v4-8-b7f379939b76@aspeedtech.com> References: <20260204-ftgmac-cleanup-v4-0-b7f379939b76@aspeedtech.com> In-Reply-To: <20260204-ftgmac-cleanup-v4-0-b7f379939b76@aspeedtech.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: , , Andrew Lunn , Jacky Chou , Simon Horman X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1770182790; l=3399; i=jacky_chou@aspeedtech.com; s=20251031; h=from:subject:message-id; bh=tSDLCPN7Gy5XtUmczxDf2SPRsE7s0Ws9LgjKXnfvqC4=; b=VgCgqTEOmUg2vbFBODrpsiettORswZAjRojrgQEoZgUF3eoShTJBYOYev9vUGVuLX6IvEslfy o+uDdtAvRtoDgO6fjfEkd0XEH6iVBIFeYkq8IKCeP8pJ5T5rk8nckx5 X-Developer-Key: i=jacky_chou@aspeedtech.com; a=ed25519; pk=8XBx7KFM1drEsfCXTH9QC2lbMlGU4XwJTA6Jt9Mabdo= From: Andrew Lunn To help reduce the complexity of the probe function move the NCSI probe code into a helper. No functional change intended. Signed-off-by: Andrew Lunn Reviewed-by: Simon Horman Signed-off-by: Jacky Chou --- drivers/net/ethernet/faraday/ftgmac100.c | 71 ++++++++++++++++++++--------= ---- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/etherne= t/faraday/ftgmac100.c index e511d6d5f7c2..1e52c4785b49 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1839,6 +1839,47 @@ static bool ftgmac100_has_child_node(struct device_n= ode *np, const char *name) return ret; } =20 +static int ftgmac100_probe_ncsi(struct net_device *netdev, + struct ftgmac100 *priv, + struct platform_device *pdev) +{ + struct device_node *np =3D pdev->dev.of_node; + struct phy_device *phydev; + int err; + + if (!IS_ENABLED(CONFIG_NET_NCSI)) { + dev_err(&pdev->dev, "NCSI stack not enabled\n"); + return -EINVAL; + } + + dev_info(&pdev->dev, "Using NCSI interface\n"); + priv->use_ncsi =3D true; + priv->ndev =3D ncsi_register_dev(netdev, ftgmac100_ncsi_handler); + if (!priv->ndev) + return -EINVAL; + + phydev =3D fixed_phy_register(&ncsi_phy_status, np); + if (IS_ERR(phydev)) { + dev_err(&pdev->dev, "failed to register fixed PHY device\n"); + err =3D PTR_ERR(phydev); + goto err_register_ndev; + } + err =3D phy_connect_direct(netdev, phydev, ftgmac100_adjust_link, + PHY_INTERFACE_MODE_RMII); + if (err) { + dev_err(&pdev->dev, "Connecting PHY failed\n"); + goto err_register_phy; + } + + return 0; +err_register_phy: + fixed_phy_unregister(phydev); +err_register_ndev: + if (priv->ndev) + ncsi_unregister_dev(priv->ndev); + return err; +} + static int ftgmac100_probe(struct platform_device *pdev) { const struct ftgmac100_match_data *match_data; @@ -1846,7 +1887,6 @@ static int ftgmac100_probe(struct platform_device *pd= ev) struct resource *res; int irq; struct net_device *netdev; - struct phy_device *phydev; struct ftgmac100 *priv; struct device_node *np; int err =3D 0; @@ -1928,32 +1968,9 @@ static int ftgmac100_probe(struct platform_device *p= dev) } =20 if (np && of_get_property(np, "use-ncsi", NULL)) { - if (!IS_ENABLED(CONFIG_NET_NCSI)) { - dev_err(&pdev->dev, "NCSI stack not enabled\n"); - err =3D -EINVAL; - goto err_phy_connect; - } - - dev_info(&pdev->dev, "Using NCSI interface\n"); - priv->use_ncsi =3D true; - priv->ndev =3D ncsi_register_dev(netdev, ftgmac100_ncsi_handler); - if (!priv->ndev) { - err =3D -EINVAL; - goto err_phy_connect; - } - - phydev =3D fixed_phy_register(&ncsi_phy_status, np); - if (IS_ERR(phydev)) { - dev_err(&pdev->dev, "failed to register fixed PHY device\n"); - err =3D PTR_ERR(phydev); - goto err_phy_connect; - } - err =3D phy_connect_direct(netdev, phydev, ftgmac100_adjust_link, - PHY_INTERFACE_MODE_RMII); - if (err) { - dev_err(&pdev->dev, "Connecting PHY failed\n"); - goto err_phy_connect; - } + err =3D ftgmac100_probe_ncsi(netdev, priv, pdev); + if (err) + goto err_setup_mdio; } else if (np && (of_phy_is_fixed_link(np) || of_get_property(np, "phy-handle", NULL))) { struct phy_device *phy; --=20 2.34.1