[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b04b1abe-c75b-4f59-b9a9-183df0c56d08@bootlin.com>
Date: Wed, 19 Nov 2025 16:04:23 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Andrew Lunn <andrew+netdev@...n.ch>, Chen-Yu Tsai <wens@...e.org>,
"David S. Miller" <davem@...emloft.net>, Drew Fustini <fustini@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Fu Wei <wefu@...hat.com>,
Guo Ren <guoren@...nel.org>, Heiko Stuebner <heiko@...ech.de>,
Jakub Kicinski <kuba@...nel.org>, Jan Petrous <jan.petrous@....nxp.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Keguang Zhang <keguang.zhang@...il.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
linux-arm-kernel@...ts.infradead.org, linux-mips@...r.kernel.org,
linux-renesas-soc@...r.kernel.org, linux-riscv@...ts.infradead.org,
linux-rockchip@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com, linux-sunxi@...ts.linux.dev,
Maxime Coquelin <mcoquelin.stm32@...il.com>, netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>, s32@....com,
Samuel Holland <samuel@...lland.org>
Subject: Re: [PATCH net-next 2/3] net: stmmac: move probe/remove calling of
init/exit
On 19/11/2025 11:03, Russell King (Oracle) wrote:
> 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) <rmk+kernel@...linux.org.uk>
Reviewed-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
Maxime
> ---
> .../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);
>
Powered by blists - more mailing lists