From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B3F6CF3188 for ; Wed, 19 Nov 2025 10:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KPfsu59Yt0PWFOvEro80t5AXlzEkyAnGNmZkqzrwQ08=; b=iRWops4dmK0JO+K24LwBj95TXq 8xsRPWrZk+8BCF1hBr5mg04racZoDl87WNJgS5JMVcD+G5q9ZO1/N0Gwc77SQfdmKEbyxC89tfGm7 wdbLDleZKT0r0vbHvrWQUZ0Q0F2N1ANoyxKP5rCnxNu3nFyJu3kYXKROObUbuDcdSuRRJqUPze4/O nMN2IG3YD38EwufTkoD3rEvehMjMmJ+sraTJk/NbXcOF/2UFhvORuznYWrVcWxS3j/LIrEBXnUrCW AQNbci9RQ3XMDiTiKjER/RLN82rm2OPMS1HfXd0J8CvL4b1n8P5bWRfBGWfIcO/mwcnY+ah2KEto7 SGXixcJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLf3I-00000002vDj-2iS1; Wed, 19 Nov 2025 10:04:40 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLf3F-00000002vBq-37oO; Wed, 19 Nov 2025 10:04:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KPfsu59Yt0PWFOvEro80t5AXlzEkyAnGNmZkqzrwQ08=; b=q3ul+T+81Zi9zcWuHHvUgADgER BzFveuxWasUnltUsKMhFpZ3ESyIvg1/o3u9GqFegfprpHjcL6COj2PiuZuyrVRfgv8UfqOtTyqiRp 1SLApR2bWJpjEEtniaNAAzGc8ectQSfqS6eczI0+DFQtK2XEU/m2rlWCoN+4fNUM+DQ8eD86f4OfR NJ/rl0935lL0UzWKz90hTr96PekeMW01mU1zdKi9Um/sh2CwkBOAgbQe3m9H9PANphlT0Tp4WlUI1 NjYsJX994DlxriT3keDjr5mkBJU6q6i6MQ/al/IMEbN6jlstqMO42C9cFeuOMNwNpITbB/kUWNCWi nN8VjxdQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:35848 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vLf2a-000000004RB-1cM3; Wed, 19 Nov 2025 10:03:56 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vLf2Z-0000000FMNH-0xPV; Wed, 19 Nov 2025 10:03:55 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , Chen-Yu Tsai , "David S. Miller" , Drew Fustini , Eric Dumazet , Fu Wei , Guo Ren , Heiko Stuebner , Jakub Kicinski , Jan Petrous , Jernej Skrabec , Keguang Zhang , Lad Prabhakar , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, Maxime Chevallier , Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , s32@nxp.com, Samuel Holland Subject: [PATCH net-next 2/3] net: stmmac: move probe/remove calling of init/exit MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Date: Wed, 19 Nov 2025 10:03:55 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251119_020437_825709_2CED3418 X-CRM114-Status: GOOD ( 16.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the probe/remove time calling of the init()/exit() methods in the platform data to the main driver probe/remove functions. This allows them to be used by non-platform_device based drivers. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 47 ++++++++++++++----- .../ethernet/stmicro/stmmac/stmmac_platform.c | 23 +-------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 644dccb29f75..aac8188248ff 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7593,19 +7593,9 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev) } EXPORT_SYMBOL_GPL(stmmac_plat_dat_alloc); -/** - * stmmac_dvr_probe - * @device: device pointer - * @plat_dat: platform data pointer - * @res: stmmac resource pointer - * Description: this is the main probe function used to - * call the alloc_etherdev, allocate the priv structure. - * Return: - * returns 0 on success, otherwise errno. - */ -int stmmac_dvr_probe(struct device *device, - struct plat_stmmacenet_data *plat_dat, - struct stmmac_resources *res) +static int __stmmac_dvr_probe(struct device *device, + struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *res) { struct net_device *ndev = NULL; struct stmmac_priv *priv; @@ -7912,6 +7902,34 @@ int stmmac_dvr_probe(struct device *device, return ret; } + +/** + * stmmac_dvr_probe + * @dev: device pointer + * @plat_dat: platform data pointer + * @res: stmmac resource pointer + * Description: this is the main probe function used to + * call the alloc_etherdev, allocate the priv structure. + * Return: + * returns 0 on success, otherwise errno. + */ +int stmmac_dvr_probe(struct device *dev, struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *res) +{ + int ret; + + if (plat_dat->init) { + ret = plat_dat->init(dev, plat_dat->bsp_priv); + if (ret) + return ret; + } + + ret = __stmmac_dvr_probe(dev, plat_dat, res); + if (ret && plat_dat->exit) + plat_dat->exit(dev, plat_dat->bsp_priv); + + return ret; +} EXPORT_SYMBOL_GPL(stmmac_dvr_probe); /** @@ -7950,6 +7968,9 @@ void stmmac_dvr_remove(struct device *dev) pm_runtime_disable(dev); pm_runtime_put_noidle(dev); + + if (priv->plat->exit) + priv->plat->exit(dev, priv->plat->bsp_priv); } EXPORT_SYMBOL_GPL(stmmac_dvr_remove); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index feccb8a3e7e8..9015b7f80d1b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -804,25 +804,12 @@ int stmmac_pltfr_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat, struct stmmac_resources *res) { - struct device *dev = &pdev->dev; - int ret; - if (!plat->suspend && plat->exit) plat->suspend = stmmac_plat_suspend; if (!plat->resume && plat->init) plat->resume = stmmac_plat_resume; - ret = stmmac_pltfr_init(dev, plat); - if (ret) - return ret; - - ret = stmmac_dvr_probe(dev, plat, res); - if (ret) { - stmmac_pltfr_exit(dev, plat); - return ret; - } - - return ret; + return stmmac_dvr_probe(&pdev->dev, plat, res); } EXPORT_SYMBOL_GPL(stmmac_pltfr_probe); @@ -864,13 +851,7 @@ EXPORT_SYMBOL_GPL(devm_stmmac_pltfr_probe); */ void stmmac_pltfr_remove(struct platform_device *pdev) { - struct net_device *ndev = platform_get_drvdata(pdev); - struct stmmac_priv *priv = netdev_priv(ndev); - struct plat_stmmacenet_data *plat = priv->plat; - struct device *dev = &pdev->dev; - - stmmac_dvr_remove(dev); - stmmac_pltfr_exit(dev, plat); + stmmac_dvr_remove(&pdev->dev); } EXPORT_SYMBOL_GPL(stmmac_pltfr_remove); -- 2.47.3