From nobody Sun Feb 8 16:30:53 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 4DBC12D7DF7; Mon, 5 Jan 2026 07:09:17 +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=1767596959; cv=none; b=uKmrbBUeSj8wFyuQeAfqVzw1kCq8+tlyYljimTxug6RpEQ/ihH2loX0gYjg5Hi//Nk8vft56N9yHYcdDcLak5Iw0mXyn9SJo0HdAn/mgR/NOn4XHAqQ0NrtIB1B9TpsCePbCMRAyB21T2aycUrLxlHjDDeZeUdzcCYXX7yC7hJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767596959; c=relaxed/simple; bh=7Ax7bydSHYyy2r/T97GJbQTSAsMABfrHie1jQIFrDv8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=l7o4OM+ZSNwgtvuUnAJ6QF5bc5kGRMy/jXhREyR3BYXsO/Jwqi/Ek3H3IakHEcXChnbryUd3eDHj3kZrD8VOT0zGZg4q0fHcDVC+Blyu/rAEPlIQgLfW81gtWCsIgqJHK/cu2cSlx2GRd6sHxNe4pL5IdHctxp5sBxE5cmRHOWo= 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; Mon, 5 Jan 2026 15:08:52 +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; Mon, 5 Jan 2026 15:08:52 +0800 From: Jacky Chou Date: Mon, 5 Jan 2026 15:08:54 +0800 Subject: [PATCH 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: <20260105-ftgmac-cleanup-v1-8-b68e4a3d8fbe@aspeedtech.com> References: <20260105-ftgmac-cleanup-v1-0-b68e4a3d8fbe@aspeedtech.com> In-Reply-To: <20260105-ftgmac-cleanup-v1-0-b68e4a3d8fbe@aspeedtech.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: , , Andrew Lunn , Jacky Chou X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1767596931; l=3185; i=jacky_chou@aspeedtech.com; s=20251031; h=from:subject:message-id; bh=mN7mgBWTZgPILPnT/PGzERdz4wjoZqx2tWvzKp+wPZQ=; b=IrGCbfxJ5aWfKR/7HVVnoOMZYJCwQCEHlSPCtG0SmJHn80SIkPvLxg5nByD9tK78CDyGS9SBE uvn+wkFD81EDncdcV7RjOmk3jpMzzY3WPobudiCcvqEWiaTdzaRuZ2U 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 help. No functional change intended. Signed-off-by: Andrew Lunn Signed-off-by: Jacky Chou --- drivers/net/ethernet/faraday/ftgmac100.c | 63 ++++++++++++++++++----------= ---- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/etherne= t/faraday/ftgmac100.c index df030d85b3ce..1bdc6793e817 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1837,6 +1837,39 @@ 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"); + return PTR_ERR(phydev); + } + err =3D phy_connect_direct(netdev, phydev, ftgmac100_adjust_link, + PHY_INTERFACE_MODE_RMII); + if (err) { + dev_err(&pdev->dev, "Connecting PHY failed\n"); + fixed_phy_unregister(phydev); + } + return err; +} + static int ftgmac100_probe(struct platform_device *pdev) { const struct ftgmac100_match_data *match_data; @@ -1844,7 +1877,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; @@ -1927,32 +1959,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