netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void
@ 2023-04-02 14:30 Uwe Kleine-König
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
                   ` (10 more replies)
  0 siblings, 11 replies; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Shawn Guo, Sascha Hauer, Vladimir Zapolskiy,
	Neil Armstrong, Kevin Hilman, Vinod Koul, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Nobuhiro Iwamatsu,
	Matthias Brugger, Thierry Reding, Jonathan Hunter
  Cc: Fabio Estevam, NXP Linux Team, Jerome Brunet,
	Martin Blumenstingl, Bhupesh Sharma, AngeloGioacchino Del Regno,
	netdev, linux-stm32, linux-arm-kernel, kernel, linux-amlogic,
	linux-oxnas, linux-sunxi, linux-mediatek, linux-tegra

Hello,

this series adapts the platform drivers below
drivers/net/ethernet/stmicro to use the .remove_new() callback. Compared
to the traditional .remove() callback .remove_new() returns no value.
This is a good thing because the driver core doesn't (and cannot) cope
for errors during remove. The only effect of a non-zero return value in
.remove() is that the driver core emits a warning. The device is removed
anyhow and an early return from .remove() usually yields a resource
leak.

The first three commits make sure that the various remove callbacks
(obviously) always return zero. After that all drivers are converted to
.remove_new().

Uwe Kleine-König (11):
  net: stmmac: Make stmmac_pltfr_remove() return void
  net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() return void
  net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition
  net: stmmac: dwmac-visconti: Convert to platform remove callback returning void
  net: stmmac: dwmac-dwc-qos-eth: Convert to platform remove callback returning void
  net: stmmac: dwmac-qcom-ethqos: Convert to platform remove callback returning void
  net: stmmac: dwmac-rk: Convert to platform remove callback returning void
  net: stmmac: dwmac-sti: Convert to platform remove callback returning void
  net: stmmac: dwmac-stm32: Convert to platform remove callback returning void
  net: stmmac: dwmac-sun8i: Convert to platform remove callback returning void
  net: stmmac: dwmac-tegra: Convert to platform remove callback returning void

 .../ethernet/stmicro/stmmac/dwmac-anarion.c   |  2 +-
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        |  6 ++----
 .../ethernet/stmicro/stmmac/dwmac-generic.c   |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-imx.c   |  2 +-
 .../ethernet/stmicro/stmmac/dwmac-ingenic.c   |  2 +-
 .../stmicro/stmmac/dwmac-intel-plat.c         |  9 +++------
 .../ethernet/stmicro/stmmac/dwmac-ipq806x.c   |  2 +-
 .../ethernet/stmicro/stmmac/dwmac-lpc18xx.c   |  2 +-
 .../ethernet/stmicro/stmmac/dwmac-mediatek.c  |  9 +++------
 .../net/ethernet/stmicro/stmmac/dwmac-meson.c |  2 +-
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-oxnas.c |  2 +-
 .../stmicro/stmmac/dwmac-qcom-ethqos.c        | 15 ++++-----------
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    |  6 ++----
 .../ethernet/stmicro/stmmac/dwmac-socfpga.c   |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-sti.c   |  6 ++----
 .../net/ethernet/stmicro/stmmac/dwmac-stm32.c |  6 ++----
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c |  6 ++----
 .../net/ethernet/stmicro/stmmac/dwmac-sunxi.c |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-tegra.c |  6 ++----
 .../ethernet/stmicro/stmmac/dwmac-visconti.c  | 19 +++++--------------
 .../ethernet/stmicro/stmmac/stmmac_platform.c |  4 +---
 .../ethernet/stmicro/stmmac/stmmac_platform.h |  2 +-
 23 files changed, 40 insertions(+), 76 deletions(-)

base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
-- 
2.39.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-02 14:41   ` Jernej Škrabec
                     ` (2 more replies)
  2023-04-02 14:30 ` [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() " Uwe Kleine-König
                   ` (9 subsequent siblings)
  10 siblings, 3 replies; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Shawn Guo, Sascha Hauer, Vladimir Zapolskiy,
	Neil Armstrong, Kevin Hilman, Vinod Koul, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Nobuhiro Iwamatsu,
	Matthias Brugger
  Cc: Fabio Estevam, NXP Linux Team, Jerome Brunet,
	Martin Blumenstingl, Bhupesh Sharma, AngeloGioacchino Del Regno,
	netdev, linux-stm32, linux-arm-kernel, kernel, linux-amlogic,
	linux-oxnas, linux-sunxi, linux-mediatek

The function returns zero unconditionally. Change it to return void instead
which simplifies some callers as error handing becomes unnecessary.

The function is also used for some drivers as remove callback. Switch these
to the .remove_new() callback. For some others no error can happen in the
remove callback now, convert them to .remove_new(), too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c         | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c  | 9 +++------
 drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c    | 9 +++------
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c       | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c       | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 5 ++---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c       | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c    | 4 +---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c   | 4 +---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h   | 2 +-
 17 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
index dfbaea06d108..747170522979 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
@@ -141,7 +141,7 @@ MODULE_DEVICE_TABLE(of, anarion_dwmac_match);
 
 static struct platform_driver anarion_dwmac_driver = {
 	.probe  = anarion_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "anarion-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
index 5e731a72cce8..18f68189b0e8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
@@ -87,7 +87,7 @@ MODULE_DEVICE_TABLE(of, dwmac_generic_match);
 
 static struct platform_driver dwmac_generic_driver = {
 	.probe  = dwmac_generic_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = STMMAC_RESOURCE_NAME,
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index ac8580f501e2..18ee4437fb2c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -350,7 +350,7 @@ MODULE_DEVICE_TABLE(of, imx_dwmac_match);
 
 static struct platform_driver imx_dwmac_driver = {
 	.probe  = imx_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "imx-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
index 378b4dd826bb..8063ba1c3ce8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
@@ -386,7 +386,7 @@ MODULE_DEVICE_TABLE(of, ingenic_mac_of_matches);
 
 static struct platform_driver ingenic_mac_driver = {
 	.probe		= ingenic_mac_probe,
-	.remove		= stmmac_pltfr_remove,
+	.remove_new	= stmmac_pltfr_remove,
 	.driver		= {
 		.name	= "ingenic-mac",
 		.pm		= pm_ptr(&ingenic_mac_pm_ops),
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index 06d287f104be..a5e639ab0b9e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -169,20 +169,17 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int intel_eth_plat_remove(struct platform_device *pdev)
+static void intel_eth_plat_remove(struct platform_device *pdev)
 {
 	struct intel_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
-	int ret;
 
-	ret = stmmac_pltfr_remove(pdev);
+	stmmac_pltfr_remove(pdev);
 	clk_disable_unprepare(dwmac->tx_clk);
-
-	return ret;
 }
 
 static struct platform_driver intel_eth_plat_driver = {
 	.probe  = intel_eth_plat_probe,
-	.remove = intel_eth_plat_remove,
+	.remove_new = intel_eth_plat_remove,
 	.driver = {
 		.name		= "intel-eth-plat",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index e888c8a9c830..e39406df8516 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -498,7 +498,7 @@ MODULE_DEVICE_TABLE(of, ipq806x_gmac_dwmac_match);
 
 static struct platform_driver ipq806x_gmac_dwmac_driver = {
 	.probe = ipq806x_gmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name		= "ipq806x-gmac-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
index 9d77c647badd..18e84ba693a6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
@@ -83,7 +83,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
 
 static struct platform_driver lpc18xx_dwmac_driver = {
 	.probe  = lpc18xx_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "lpc18xx-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 2f7d8e4561d9..fe18d6db0e1d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -678,15 +678,12 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int mediatek_dwmac_remove(struct platform_device *pdev)
+static void mediatek_dwmac_remove(struct platform_device *pdev)
 {
 	struct mediatek_dwmac_plat_data *priv_plat = get_stmmac_bsp_priv(&pdev->dev);
-	int ret;
 
-	ret = stmmac_pltfr_remove(pdev);
+	stmmac_pltfr_remove(pdev);
 	mediatek_dwmac_clks_config(priv_plat, false);
-
-	return ret;
 }
 
 static const struct of_device_id mediatek_dwmac_match[] = {
@@ -701,7 +698,7 @@ MODULE_DEVICE_TABLE(of, mediatek_dwmac_match);
 
 static struct platform_driver mediatek_dwmac_driver = {
 	.probe  = mediatek_dwmac_probe,
-	.remove = mediatek_dwmac_remove,
+	.remove_new = mediatek_dwmac_remove,
 	.driver = {
 		.name           = "dwmac-mediatek",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
index 16fb66a0ca72..7aa5e6bc04eb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -91,7 +91,7 @@ MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
 
 static struct platform_driver meson6_dwmac_driver = {
 	.probe  = meson6_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "meson6-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index e8b507f88fbc..0b2e3c5efbb2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -535,7 +535,7 @@ MODULE_DEVICE_TABLE(of, meson8b_dwmac_match);
 
 static struct platform_driver meson8b_dwmac_driver = {
 	.probe  = meson8b_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "meson8b-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
index 62a69a91ab22..42954020de2c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
@@ -231,7 +231,7 @@ MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
 
 static struct platform_driver oxnas_dwmac_driver = {
 	.probe  = oxnas_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "oxnas-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 732774645c1a..f9faa6f55939 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -581,16 +581,15 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 static int qcom_ethqos_remove(struct platform_device *pdev)
 {
 	struct qcom_ethqos *ethqos;
-	int ret;
 
 	ethqos = get_stmmac_bsp_priv(&pdev->dev);
 	if (!ethqos)
 		return -ENODEV;
 
-	ret = stmmac_pltfr_remove(pdev);
+	stmmac_pltfr_remove(pdev);
 	ethqos_clks_config(ethqos, false);
 
-	return ret;
+	return 0;
 }
 
 static const struct of_device_id qcom_ethqos_match[] = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 6b447d8f0bd8..6ee050300b31 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -524,7 +524,7 @@ MODULE_DEVICE_TABLE(of, socfpga_dwmac_match);
 
 static struct platform_driver socfpga_dwmac_driver = {
 	.probe  = socfpga_dwmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "socfpga-dwmac",
 		.pm		= &socfpga_dwmac_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index fc3b0acc8f99..50963e91c347 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -179,7 +179,7 @@ MODULE_DEVICE_TABLE(of, sun7i_dwmac_match);
 
 static struct platform_driver sun7i_dwmac_driver = {
 	.probe  = sun7i_gmac_probe,
-	.remove = stmmac_pltfr_remove,
+	.remove_new = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "sun7i-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index c3f10a92b62b..d43da71eb1e1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -265,9 +265,7 @@ static int visconti_eth_dwmac_remove(struct platform_device *pdev)
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	int err;
 
-	err = stmmac_pltfr_remove(pdev);
-	if (err < 0)
-		dev_err(&pdev->dev, "failed to remove platform: %d\n", err);
+	stmmac_pltfr_remove(pdev);
 
 	err = visconti_eth_clock_remove(pdev);
 	if (err < 0)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 067a40fe0a23..d9a3fab2f94b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -706,7 +706,7 @@ EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
  * Description: this function calls the main to free the net resources
  * and calls the platforms hook and release the resources (e.g. mem).
  */
-int stmmac_pltfr_remove(struct platform_device *pdev)
+void stmmac_pltfr_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
@@ -718,8 +718,6 @@ int stmmac_pltfr_remove(struct platform_device *pdev)
 		plat->exit(pdev, plat->bsp_priv);
 
 	stmmac_remove_config_dt(pdev, plat);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(stmmac_pltfr_remove);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 3fff3f59d73d..f7e457946681 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -19,7 +19,7 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res);
 
-int stmmac_pltfr_remove(struct platform_device *pdev);
+void stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
 static inline void *get_stmmac_bsp_priv(struct device *dev)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() return void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-02 17:02   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition Uwe Kleine-König
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Nobuhiro Iwamatsu
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The function returns zero unconditionally. Change it to return void
instead which simplifies one caller as error handing becomes
unnecessary.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index d43da71eb1e1..7531fcd4ffe2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -198,7 +198,7 @@ static int visconti_eth_clock_probe(struct platform_device *pdev,
 	return 0;
 }
 
-static int visconti_eth_clock_remove(struct platform_device *pdev)
+static void visconti_eth_clock_remove(struct platform_device *pdev)
 {
 	struct visconti_eth *dwmac = get_stmmac_bsp_priv(&pdev->dev);
 	struct net_device *ndev = platform_get_drvdata(pdev);
@@ -206,8 +206,6 @@ static int visconti_eth_clock_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(dwmac->phy_ref_clk);
 	clk_disable_unprepare(priv->plat->stmmac_clk);
-
-	return 0;
 }
 
 static int visconti_eth_dwmac_probe(struct platform_device *pdev)
@@ -267,9 +265,7 @@ static int visconti_eth_dwmac_remove(struct platform_device *pdev)
 
 	stmmac_pltfr_remove(pdev);
 
-	err = visconti_eth_clock_remove(pdev);
-	if (err < 0)
-		dev_err(&pdev->dev, "failed to remove clock: %d\n", err);
+	visconti_eth_clock_remove(pdev);
 
 	stmmac_remove_config_dt(pdev, priv->plat);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
  2023-04-02 14:30 ` [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:47   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Vinod Koul, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: Bhupesh Sharma, netdev, linux-stm32, linux-arm-kernel, kernel

The remove callback is only ever called after .probe() returned
successfully. After that get_stmmac_bsp_priv() always return non-NULL.

Side note: The early exit would also be a bug because the return value
of qcom_ethqos_remove() is ignored by the device core and the device is
unbound unconditionally. So exiting early resulted in a dangerous
resource leak as all devm allocated resources (some memory and the
register mappings) are freed but the network device stays around.  Using
the network device afterwards probably oopses.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index f9faa6f55939..fba1fc88d2dc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -580,11 +580,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 
 static int qcom_ethqos_remove(struct platform_device *pdev)
 {
-	struct qcom_ethqos *ethqos;
-
-	ethqos = get_stmmac_bsp_priv(&pdev->dev);
-	if (!ethqos)
-		return -ENODEV;
+	struct qcom_ethqos *ethqos = get_stmmac_bsp_priv(&pdev->dev);
 
 	stmmac_pltfr_remove(pdev);
 	ethqos_clks_config(ethqos, false);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:46   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: " Uwe Kleine-König
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Nobuhiro Iwamatsu
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index 7531fcd4ffe2..acbb284be174 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -257,19 +257,16 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int visconti_eth_dwmac_remove(struct platform_device *pdev)
+static void visconti_eth_dwmac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
-	int err;
 
 	stmmac_pltfr_remove(pdev);
 
 	visconti_eth_clock_remove(pdev);
 
 	stmmac_remove_config_dt(pdev, priv->plat);
-
-	return err;
 }
 
 static const struct of_device_id visconti_eth_dwmac_match[] = {
@@ -280,7 +277,7 @@ MODULE_DEVICE_TABLE(of, visconti_eth_dwmac_match);
 
 static struct platform_driver visconti_eth_dwmac_driver = {
 	.probe  = visconti_eth_dwmac_probe,
-	.remove = visconti_eth_dwmac_remove,
+	.remove_new = visconti_eth_dwmac_remove,
 	.driver = {
 		.name           = "visconti-eth-dwmac",
 		.of_match_table = visconti_eth_dwmac_match,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:49   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: " Uwe Kleine-König
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 18acf7dd74e5..9f88530c5e8c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -464,7 +464,7 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int dwc_eth_dwmac_remove(struct platform_device *pdev)
+static void dwc_eth_dwmac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
@@ -477,8 +477,6 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
 	data->remove(pdev);
 
 	stmmac_remove_config_dt(pdev, priv->plat);
-
-	return 0;
 }
 
 static const struct of_device_id dwc_eth_dwmac_match[] = {
@@ -490,7 +488,7 @@ MODULE_DEVICE_TABLE(of, dwc_eth_dwmac_match);
 
 static struct platform_driver dwc_eth_dwmac_driver = {
 	.probe  = dwc_eth_dwmac_probe,
-	.remove = dwc_eth_dwmac_remove,
+	.remove_new = dwc_eth_dwmac_remove,
 	.driver = {
 		.name           = "dwc-eth-dwmac",
 		.pm             = &stmmac_pltfr_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:49   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 07/11] net: stmmac: dwmac-rk: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Vinod Koul, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: Bhupesh Sharma, netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index fba1fc88d2dc..de2f0df1f67c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -578,14 +578,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int qcom_ethqos_remove(struct platform_device *pdev)
+static void qcom_ethqos_remove(struct platform_device *pdev)
 {
 	struct qcom_ethqos *ethqos = get_stmmac_bsp_priv(&pdev->dev);
 
 	stmmac_pltfr_remove(pdev);
 	ethqos_clks_config(ethqos, false);
-
-	return 0;
 }
 
 static const struct of_device_id qcom_ethqos_match[] = {
@@ -597,7 +595,7 @@ MODULE_DEVICE_TABLE(of, qcom_ethqos_match);
 
 static struct platform_driver qcom_ethqos_driver = {
 	.probe  = qcom_ethqos_probe,
-	.remove = qcom_ethqos_remove,
+	.remove_new = qcom_ethqos_remove,
 	.driver = {
 		.name           = "qcom-ethqos",
 		.pm		= &stmmac_pltfr_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 07/11] net: stmmac: dwmac-rk: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:50   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 08/11] net: stmmac: dwmac-sti: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 4b8fd11563e4..82b23d182db6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1912,15 +1912,13 @@ static int rk_gmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int rk_gmac_remove(struct platform_device *pdev)
+static void rk_gmac_remove(struct platform_device *pdev)
 {
 	struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
 
 	stmmac_dvr_remove(&pdev->dev);
 
 	rk_gmac_powerdown(bsp_priv);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1974,7 +1972,7 @@ MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);
 
 static struct platform_driver rk_gmac_dwmac_driver = {
 	.probe  = rk_gmac_probe,
-	.remove = rk_gmac_remove,
+	.remove_new = rk_gmac_remove,
 	.driver = {
 		.name           = "rk_gmac-dwmac",
 		.pm		= &rk_gmac_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 08/11] net: stmmac: dwmac-sti: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 07/11] net: stmmac: dwmac-rk: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:52   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 09/11] net: stmmac: dwmac-stm32: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index be3b1ebc06ab..0411bab64dc7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -368,15 +368,13 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int sti_dwmac_remove(struct platform_device *pdev)
+static void sti_dwmac_remove(struct platform_device *pdev)
 {
 	struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
 
 	stmmac_dvr_remove(&pdev->dev);
 
 	clk_disable_unprepare(dwmac->clk);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -423,7 +421,7 @@ MODULE_DEVICE_TABLE(of, sti_dwmac_match);
 
 static struct platform_driver sti_dwmac_driver = {
 	.probe  = sti_dwmac_probe,
-	.remove = sti_dwmac_remove,
+	.remove_new = sti_dwmac_remove,
 	.driver = {
 		.name           = "sti-dwmac",
 		.pm		= &sti_dwmac_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 09/11] net: stmmac: dwmac-stm32: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 08/11] net: stmmac: dwmac-sti: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:52   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: " Uwe Kleine-König
  2023-04-02 14:30 ` [PATCH net-next 11/11] net: stmmac: dwmac-tegra: " Uwe Kleine-König
  10 siblings, 1 reply; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: netdev, linux-stm32, linux-arm-kernel, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 0616b3a04ff3..bdb4de59a672 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -417,7 +417,7 @@ static int stm32_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int stm32_dwmac_remove(struct platform_device *pdev)
+static void stm32_dwmac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
@@ -431,8 +431,6 @@ static int stm32_dwmac_remove(struct platform_device *pdev)
 		dev_pm_clear_wake_irq(&pdev->dev);
 		device_init_wakeup(&pdev->dev, false);
 	}
-
-	return 0;
 }
 
 static int stm32mp1_suspend(struct stm32_dwmac *dwmac)
@@ -528,7 +526,7 @@ MODULE_DEVICE_TABLE(of, stm32_dwmac_match);
 
 static struct platform_driver stm32_dwmac_driver = {
 	.probe  = stm32_dwmac_probe,
-	.remove = stm32_dwmac_remove,
+	.remove_new = stm32_dwmac_remove,
 	.driver = {
 		.name           = "stm32-dwmac",
 		.pm		= &stm32_dwmac_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 09/11] net: stmmac: dwmac-stm32: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-02 14:41   ` Jernej Škrabec
  2023-04-03 15:52   ` Simon Horman
  2023-04-02 14:30 ` [PATCH net-next 11/11] net: stmmac: dwmac-tegra: " Uwe Kleine-König
  10 siblings, 2 replies; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Maxime Coquelin
  Cc: netdev, linux-arm-kernel, linux-sunxi, linux-stm32, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index f834472599f7..b12927c799ce 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1282,7 +1282,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int sun8i_dwmac_remove(struct platform_device *pdev)
+static void sun8i_dwmac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
@@ -1297,8 +1297,6 @@ static int sun8i_dwmac_remove(struct platform_device *pdev)
 
 	stmmac_pltfr_remove(pdev);
 	sun8i_dwmac_unset_syscon(gmac);
-
-	return 0;
 }
 
 static void sun8i_dwmac_shutdown(struct platform_device *pdev)
@@ -1329,7 +1327,7 @@ MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
 
 static struct platform_driver sun8i_dwmac_driver = {
 	.probe  = sun8i_dwmac_probe,
-	.remove = sun8i_dwmac_remove,
+	.remove_new = sun8i_dwmac_remove,
 	.shutdown = sun8i_dwmac_shutdown,
 	.driver = {
 		.name           = "dwmac-sun8i",
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next 11/11] net: stmmac: dwmac-tegra: Convert to platform remove callback returning void
  2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2023-04-02 14:30 ` [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: " Uwe Kleine-König
@ 2023-04-02 14:30 ` Uwe Kleine-König
  2023-04-03 15:54   ` Simon Horman
  2023-04-04 11:16   ` Thierry Reding
  10 siblings, 2 replies; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-02 14:30 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Thierry Reding, Jonathan Hunter
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-tegra, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
index bdf990cf2f31..f8367c5b490b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
@@ -353,15 +353,13 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int tegra_mgbe_remove(struct platform_device *pdev)
+static void tegra_mgbe_remove(struct platform_device *pdev)
 {
 	struct tegra_mgbe *mgbe = get_stmmac_bsp_priv(&pdev->dev);
 
 	clk_bulk_disable_unprepare(ARRAY_SIZE(mgbe_clks), mgbe->clks);
 
 	stmmac_pltfr_remove(pdev);
-
-	return 0;
 }
 
 static const struct of_device_id tegra_mgbe_match[] = {
@@ -374,7 +372,7 @@ static SIMPLE_DEV_PM_OPS(tegra_mgbe_pm_ops, tegra_mgbe_suspend, tegra_mgbe_resum
 
 static struct platform_driver tegra_mgbe_driver = {
 	.probe = tegra_mgbe_probe,
-	.remove = tegra_mgbe_remove,
+	.remove_new = tegra_mgbe_remove,
 	.driver = {
 		.name = "tegra-mgbe",
 		.pm		= &tegra_mgbe_pm_ops,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
@ 2023-04-02 14:41   ` Jernej Škrabec
  2023-04-03 15:55   ` Simon Horman
  2023-04-03 20:39   ` Martin Blumenstingl
  2 siblings, 0 replies; 28+ messages in thread
From: Jernej Škrabec @ 2023-04-02 14:41 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Shawn Guo, Sascha Hauer, Vladimir Zapolskiy,
	Neil Armstrong, Kevin Hilman, Vinod Koul, Chen-Yu Tsai,
	Samuel Holland, Nobuhiro Iwamatsu, Matthias Brugger,
	Uwe Kleine-König
  Cc: Fabio Estevam, NXP Linux Team, Jerome Brunet,
	Martin Blumenstingl, Bhupesh Sharma, AngeloGioacchino Del Regno,
	netdev, linux-stm32, linux-arm-kernel, kernel, linux-amlogic,
	linux-oxnas, linux-sunxi, linux-mediatek

Dne nedelja, 02. april 2023 ob 16:30:15 CEST je Uwe Kleine-König napisal(a):
> The function returns zero unconditionally. Change it to return void instead
> which simplifies some callers as error handing becomes unnecessary.
> 
> The function is also used for some drivers as remove callback. Switch these
> to the .remove_new() callback. For some others no error can happen in the
> remove callback now, convert them to .remove_new(), too.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c         | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c  | 9 +++------
>  drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c    | 9 +++------
>  drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c       | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c       | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 5 ++---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c       | 2 +-

For sunxi:
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

>  drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c    | 4 +---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c   | 4 +---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h   | 2 +-
>  17 files changed, 22 insertions(+), 33 deletions(-)




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: " Uwe Kleine-König
@ 2023-04-02 14:41   ` Jernej Škrabec
  2023-04-03 15:52   ` Simon Horman
  1 sibling, 0 replies; 28+ messages in thread
From: Jernej Škrabec @ 2023-04-02 14:41 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Chen-Yu Tsai, Samuel Holland, Maxime Coquelin,
	Uwe Kleine-König
  Cc: netdev, linux-arm-kernel, linux-sunxi, linux-stm32, kernel

Dne nedelja, 02. april 2023 ob 16:30:24 CEST je Uwe Kleine-König napisal(a):
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

For sunxi:
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() return void
  2023-04-02 14:30 ` [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() " Uwe Kleine-König
@ 2023-04-02 17:02   ` Simon Horman
  2023-04-03  5:52     ` Uwe Kleine-König
  0 siblings, 1 reply; 28+ messages in thread
From: Simon Horman @ 2023-04-02 17:02 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Nobuhiro Iwamatsu, netdev, linux-stm32,
	linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:16PM +0200, Uwe Kleine-König wrote:
> The function returns zero unconditionally. Change it to return void
> instead which simplifies one caller as error handing becomes
> unnecessary.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

...

> @@ -267,9 +265,7 @@ static int visconti_eth_dwmac_remove(struct platform_device *pdev)
>  
>  	stmmac_pltfr_remove(pdev);
>  
> -	err = visconti_eth_clock_remove(pdev);
> -	if (err < 0)
> -		dev_err(&pdev->dev, "failed to remove clock: %d\n", err);
> +	visconti_eth_clock_remove(pdev);
>  
>  	stmmac_remove_config_dt(pdev, priv->plat);

err is now returned uninitialised by this function.

I see that err is removed in a later patch.
But perhaps it's best to make this patch clean in this regard too.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() return void
  2023-04-02 17:02   ` Simon Horman
@ 2023-04-03  5:52     ` Uwe Kleine-König
  0 siblings, 0 replies; 28+ messages in thread
From: Uwe Kleine-König @ 2023-04-03  5:52 UTC (permalink / raw)
  To: Simon Horman
  Cc: kernel, netdev, Alexandre Torgue, linux-stm32, Eric Dumazet,
	Jose Abreu, Maxime Coquelin, Jakub Kicinski, Giuseppe Cavallaro,
	Nobuhiro Iwamatsu, Paolo Abeni, David S. Miller,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]

Hello Simon,

On Sun, Apr 02, 2023 at 07:02:26PM +0200, Simon Horman wrote:
> On Sun, Apr 02, 2023 at 04:30:16PM +0200, Uwe Kleine-König wrote:
> > The function returns zero unconditionally. Change it to return void
> > instead which simplifies one caller as error handing becomes
> > unnecessary.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> ...
> 
> > @@ -267,9 +265,7 @@ static int visconti_eth_dwmac_remove(struct platform_device *pdev)
> >  
> >  	stmmac_pltfr_remove(pdev);
> >  
> > -	err = visconti_eth_clock_remove(pdev);
> > -	if (err < 0)
> > -		dev_err(&pdev->dev, "failed to remove clock: %d\n", err);
> > +	visconti_eth_clock_remove(pdev);
> >  
> >  	stmmac_remove_config_dt(pdev, priv->plat);
> 
> err is now returned uninitialised by this function.

Good catch. Indeed err must be removed in this patch and return err
replaced by return 0. I'll send a v2 later this week, waiting a bit for
further feedback.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-04-03 15:46   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:46 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Nobuhiro Iwamatsu, netdev, linux-stm32,
	linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:18PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> index 7531fcd4ffe2..acbb284be174 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> @@ -257,19 +257,16 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int visconti_eth_dwmac_remove(struct platform_device *pdev)
> +static void visconti_eth_dwmac_remove(struct platform_device *pdev)
>  {
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct stmmac_priv *priv = netdev_priv(ndev);
> -	int err;

As noted elsewhere, err is returned uninitialised since patch 02/11.
Which will be fixed in v2 :)

[1] https://lore.kernel.org/all/20230403055221.xugl42vub7ugo3tz@pengutronix.de/

That notwithstanding,

Reviewed-by: Simon Horman <simon.horman@corigine.com>

>  	stmmac_pltfr_remove(pdev);
>  
>  	visconti_eth_clock_remove(pdev);
>  
>  	stmmac_remove_config_dt(pdev, priv->plat);
> -
> -	return err;
>  }
>  
>  static const struct of_device_id visconti_eth_dwmac_match[] = {
> @@ -280,7 +277,7 @@ MODULE_DEVICE_TABLE(of, visconti_eth_dwmac_match);
>  
>  static struct platform_driver visconti_eth_dwmac_driver = {
>  	.probe  = visconti_eth_dwmac_probe,
> -	.remove = visconti_eth_dwmac_remove,
> +	.remove_new = visconti_eth_dwmac_remove,
>  	.driver = {
>  		.name           = "visconti-eth-dwmac",
>  		.of_match_table = visconti_eth_dwmac_match,
> -- 
> 2.39.2
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition
  2023-04-02 14:30 ` [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition Uwe Kleine-König
@ 2023-04-03 15:47   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:47 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Vinod Koul, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Bhupesh Sharma, netdev, linux-stm32,
	linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:17PM +0200, Uwe Kleine-König wrote:
> The remove callback is only ever called after .probe() returned
> successfully. After that get_stmmac_bsp_priv() always return non-NULL.
> 
> Side note: The early exit would also be a bug because the return value
> of qcom_ethqos_remove() is ignored by the device core and the device is
> unbound unconditionally. So exiting early resulted in a dangerous
> resource leak as all devm allocated resources (some memory and the
> register mappings) are freed but the network device stays around.  Using
> the network device afterwards probably oopses.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>


Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: " Uwe Kleine-König
@ 2023-04-03 15:49   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:49 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:19PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: " Uwe Kleine-König
@ 2023-04-03 15:49   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:49 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Vinod Koul, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Bhupesh Sharma, netdev, linux-stm32,
	linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:20PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 07/11] net: stmmac: dwmac-rk: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 07/11] net: stmmac: dwmac-rk: " Uwe Kleine-König
@ 2023-04-03 15:50   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:50 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:21PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 08/11] net: stmmac: dwmac-sti: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 08/11] net: stmmac: dwmac-sti: " Uwe Kleine-König
@ 2023-04-03 15:52   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:52 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:22PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 09/11] net: stmmac: dwmac-stm32: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 09/11] net: stmmac: dwmac-stm32: " Uwe Kleine-König
@ 2023-04-03 15:52   ` Simon Horman
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:52 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel, kernel

On Sun, Apr 02, 2023 at 04:30:23PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: " Uwe Kleine-König
  2023-04-02 14:41   ` Jernej Škrabec
@ 2023-04-03 15:52   ` Simon Horman
  1 sibling, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:52 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Maxime Coquelin,
	netdev, linux-arm-kernel, linux-sunxi, linux-stm32, kernel

On Sun, Apr 02, 2023 at 04:30:24PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 11/11] net: stmmac: dwmac-tegra: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 11/11] net: stmmac: dwmac-tegra: " Uwe Kleine-König
@ 2023-04-03 15:54   ` Simon Horman
  2023-04-04 11:16   ` Thierry Reding
  1 sibling, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:54 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Thierry Reding, Jonathan Hunter, netdev,
	linux-stm32, linux-arm-kernel, linux-tegra, kernel

On Sun, Apr 02, 2023 at 04:30:25PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
  2023-04-02 14:41   ` Jernej Škrabec
@ 2023-04-03 15:55   ` Simon Horman
  2023-04-03 20:39   ` Martin Blumenstingl
  2 siblings, 0 replies; 28+ messages in thread
From: Simon Horman @ 2023-04-03 15:55 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Shawn Guo, Sascha Hauer, Vladimir Zapolskiy,
	Neil Armstrong, Kevin Hilman, Vinod Koul, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Nobuhiro Iwamatsu,
	Matthias Brugger, Fabio Estevam, NXP Linux Team, Jerome Brunet,
	Martin Blumenstingl, Bhupesh Sharma, AngeloGioacchino Del Regno,
	netdev, linux-stm32, linux-arm-kernel, kernel, linux-amlogic,
	linux-oxnas, linux-sunxi, linux-mediatek

On Sun, Apr 02, 2023 at 04:30:15PM +0200, Uwe Kleine-König wrote:
> The function returns zero unconditionally. Change it to return void instead
> which simplifies some callers as error handing becomes unnecessary.
> 
> The function is also used for some drivers as remove callback. Switch these
> to the .remove_new() callback. For some others no error can happen in the
> remove callback now, convert them to .remove_new(), too.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void
  2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
  2023-04-02 14:41   ` Jernej Škrabec
  2023-04-03 15:55   ` Simon Horman
@ 2023-04-03 20:39   ` Martin Blumenstingl
  2 siblings, 0 replies; 28+ messages in thread
From: Martin Blumenstingl @ 2023-04-03 20:39 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Shawn Guo, Sascha Hauer, Vladimir Zapolskiy,
	Neil Armstrong, Kevin Hilman, Vinod Koul, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Nobuhiro Iwamatsu,
	Matthias Brugger, Fabio Estevam, NXP Linux Team, Jerome Brunet,
	Bhupesh Sharma, AngeloGioacchino Del Regno, netdev, linux-stm32,
	linux-arm-kernel, kernel, linux-amlogic, linux-oxnas,
	linux-sunxi, linux-mediatek

On Sun, Apr 2, 2023 at 4:31 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> The function returns zero unconditionally. Change it to return void instead
> which simplifies some callers as error handing becomes unnecessary.
>
> The function is also used for some drivers as remove callback. Switch these
> to the .remove_new() callback. For some others no error can happen in the
> remove callback now, convert them to .remove_new(), too.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c         | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c  | 9 +++------
>  drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c     | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c    | 9 +++------
>  drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c       | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c     | 2 +-
for dwmac-meson and dwmac-meson8b:
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next 11/11] net: stmmac: dwmac-tegra: Convert to platform remove callback returning void
  2023-04-02 14:30 ` [PATCH net-next 11/11] net: stmmac: dwmac-tegra: " Uwe Kleine-König
  2023-04-03 15:54   ` Simon Horman
@ 2023-04-04 11:16   ` Thierry Reding
  1 sibling, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2023-04-04 11:16 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Jonathan Hunter, netdev, linux-stm32,
	linux-arm-kernel, linux-tegra, kernel

[-- Attachment #1: Type: text/plain, Size: 896 bytes --]

On Sun, Apr 02, 2023 at 04:30:25PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-04-04 11:16 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-02 14:30 [PATCH net-next 00/11] net: stmmac: Convert to platform remove callback returning void Uwe Kleine-König
2023-04-02 14:30 ` [PATCH net-next 01/11] net: stmmac: Make stmmac_pltfr_remove() return void Uwe Kleine-König
2023-04-02 14:41   ` Jernej Škrabec
2023-04-03 15:55   ` Simon Horman
2023-04-03 20:39   ` Martin Blumenstingl
2023-04-02 14:30 ` [PATCH net-next 02/11] net: stmmac: dwmac-visconti: Make visconti_eth_clock_remove() " Uwe Kleine-König
2023-04-02 17:02   ` Simon Horman
2023-04-03  5:52     ` Uwe Kleine-König
2023-04-02 14:30 ` [PATCH net-next 03/11] net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition Uwe Kleine-König
2023-04-03 15:47   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 04/11] net: stmmac: dwmac-visconti: Convert to platform remove callback returning void Uwe Kleine-König
2023-04-03 15:46   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 05/11] net: stmmac: dwmac-dwc-qos-eth: " Uwe Kleine-König
2023-04-03 15:49   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 06/11] net: stmmac: dwmac-qcom-ethqos: " Uwe Kleine-König
2023-04-03 15:49   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 07/11] net: stmmac: dwmac-rk: " Uwe Kleine-König
2023-04-03 15:50   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 08/11] net: stmmac: dwmac-sti: " Uwe Kleine-König
2023-04-03 15:52   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 09/11] net: stmmac: dwmac-stm32: " Uwe Kleine-König
2023-04-03 15:52   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 10/11] net: stmmac: dwmac-sun8i: " Uwe Kleine-König
2023-04-02 14:41   ` Jernej Škrabec
2023-04-03 15:52   ` Simon Horman
2023-04-02 14:30 ` [PATCH net-next 11/11] net: stmmac: dwmac-tegra: " Uwe Kleine-König
2023-04-03 15:54   ` Simon Horman
2023-04-04 11:16   ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).