linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] fpga: Convert to platform remove callback returning void
@ 2023-12-19 17:31 Uwe Kleine-König
  2023-12-19 17:31 ` [PATCH 01/13] fpga: altera-fpga2sdram: " Uwe Kleine-König
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:31 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun
  Cc: Tom Rix, linux-fpga, kernel, Peter Colberg, Michal Simek,
	linux-arm-kernel

Hello,

this series converts all drivers below drivers/fpga to use
.remove_new(). See commit 5c5a7680e67b ("platform: Provide a remove
callback that returns no value") for an extended explanation and the
eventual goal. The TL;DR; is to make it harder for driver authors to
leak resources without noticing.

This is merge window material. All patches are pairwise independent of
each other, so they could be applied individually. Getting them all in
together would be nicer though :-)

Best regards
Uwe

Uwe Kleine-König (13):
  fpga: altera-fpga2sdram: Convert to platform remove callback returning void
  fpga: altera-freeze-bridge: Convert to platform remove callback returning void
  fpga: altera-hps2fpga: Convert to platform remove callback returning void
  fpga: dfl-afu-main: Convert to platform remove callback returning void
  fpga: dfl-fme-br: Convert to platform remove callback returning void
  fpga: dfl-fme-main: Convert to platform remove callback returning void
  fpga: dfl-fme-region: Convert to platform remove callback returning void
  fpga: intel-m10-bmc-sec-update: Convert to platform remove callback returning void
  fpga: of-fpga-region: Convert to platform remove callback returning void
  fpga: socfpga-a10: Convert to platform remove callback returning void
  fpga: stratix10-soc: Convert to platform remove callback returning void
  fpga: xilinx-pr-decoupler: Convert to platform remove callback returning void
  fpga: zynq-fpga: Convert to platform remove callback returning void

 drivers/fpga/altera-fpga2sdram.c        | 6 ++----
 drivers/fpga/altera-freeze-bridge.c     | 6 ++----
 drivers/fpga/altera-hps2fpga.c          | 6 ++----
 drivers/fpga/dfl-afu-main.c             | 6 ++----
 drivers/fpga/dfl-fme-br.c               | 6 ++----
 drivers/fpga/dfl-fme-main.c             | 6 ++----
 drivers/fpga/dfl-fme-region.c           | 6 ++----
 drivers/fpga/intel-m10-bmc-sec-update.c | 6 ++----
 drivers/fpga/of-fpga-region.c           | 6 ++----
 drivers/fpga/socfpga-a10.c              | 6 ++----
 drivers/fpga/stratix10-soc.c            | 6 ++----
 drivers/fpga/xilinx-pr-decoupler.c      | 6 ++----
 drivers/fpga/zynq-fpga.c                | 6 ++----
 13 files changed, 26 insertions(+), 52 deletions(-)

base-commit: aa4db8324c4d0e67aa4670356df4e9fae14b4d37
-- 
2.42.0


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

* [PATCH 01/13] fpga: altera-fpga2sdram: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-12-19 17:31 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 02/13] fpga: altera-freeze-bridge: " Uwe Kleine-König
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:31 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/altera-fpga2sdram.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/altera-fpga2sdram.c b/drivers/fpga/altera-fpga2sdram.c
index 1fa2ccc321ab..6b60ca004345 100644
--- a/drivers/fpga/altera-fpga2sdram.c
+++ b/drivers/fpga/altera-fpga2sdram.c
@@ -147,20 +147,18 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int alt_fpga_bridge_remove(struct platform_device *pdev)
+static void alt_fpga_bridge_remove(struct platform_device *pdev)
 {
 	struct fpga_bridge *br = platform_get_drvdata(pdev);
 
 	fpga_bridge_unregister(br);
-
-	return 0;
 }
 
 MODULE_DEVICE_TABLE(of, altera_fpga_of_match);
 
 static struct platform_driver altera_fpga_driver = {
 	.probe = alt_fpga_bridge_probe,
-	.remove = alt_fpga_bridge_remove,
+	.remove_new = alt_fpga_bridge_remove,
 	.driver = {
 		.name	= "altera_fpga2sdram_bridge",
 		.of_match_table = of_match_ptr(altera_fpga_of_match),
-- 
2.42.0


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

* [PATCH 02/13] fpga: altera-freeze-bridge: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
  2023-12-19 17:31 ` [PATCH 01/13] fpga: altera-fpga2sdram: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 03/13] fpga: altera-hps2fpga: " Uwe Kleine-König
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/altera-freeze-bridge.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/altera-freeze-bridge.c b/drivers/fpga/altera-freeze-bridge.c
index 0c3fb8226908..44061cb16f87 100644
--- a/drivers/fpga/altera-freeze-bridge.c
+++ b/drivers/fpga/altera-freeze-bridge.c
@@ -253,18 +253,16 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int altera_freeze_br_remove(struct platform_device *pdev)
+static void altera_freeze_br_remove(struct platform_device *pdev)
 {
 	struct fpga_bridge *br = platform_get_drvdata(pdev);
 
 	fpga_bridge_unregister(br);
-
-	return 0;
 }
 
 static struct platform_driver altera_freeze_br_driver = {
 	.probe = altera_freeze_br_probe,
-	.remove = altera_freeze_br_remove,
+	.remove_new = altera_freeze_br_remove,
 	.driver = {
 		.name	= "altera_freeze_br",
 		.of_match_table = altera_freeze_br_of_match,
-- 
2.42.0


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

* [PATCH 03/13] fpga: altera-hps2fpga: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
  2023-12-19 17:31 ` [PATCH 01/13] fpga: altera-fpga2sdram: " Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 02/13] fpga: altera-freeze-bridge: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 04/13] fpga: dfl-afu-main: " Uwe Kleine-König
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/altera-hps2fpga.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
index 578663503297..6f8e24be19c6 100644
--- a/drivers/fpga/altera-hps2fpga.c
+++ b/drivers/fpga/altera-hps2fpga.c
@@ -191,7 +191,7 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int alt_fpga_bridge_remove(struct platform_device *pdev)
+static void alt_fpga_bridge_remove(struct platform_device *pdev)
 {
 	struct fpga_bridge *bridge = platform_get_drvdata(pdev);
 	struct altera_hps2fpga_data *priv = bridge->priv;
@@ -199,15 +199,13 @@ static int alt_fpga_bridge_remove(struct platform_device *pdev)
 	fpga_bridge_unregister(bridge);
 
 	clk_disable_unprepare(priv->clk);
-
-	return 0;
 }
 
 MODULE_DEVICE_TABLE(of, altera_fpga_of_match);
 
 static struct platform_driver alt_fpga_bridge_driver = {
 	.probe = alt_fpga_bridge_probe,
-	.remove = alt_fpga_bridge_remove,
+	.remove_new = alt_fpga_bridge_remove,
 	.driver = {
 		.name	= "altera_hps2fpga_bridge",
 		.of_match_table = of_match_ptr(altera_fpga_of_match),
-- 
2.42.0


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

* [PATCH 04/13] fpga: dfl-afu-main: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 03/13] fpga: altera-hps2fpga: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 05/13] fpga: dfl-fme-br: " Uwe Kleine-König
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Wu Hao, Moritz Fischer, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/dfl-afu-main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 7f621e96d3b8..c0a75ca360d6 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -932,15 +932,13 @@ static int afu_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int afu_remove(struct platform_device *pdev)
+static void afu_remove(struct platform_device *pdev)
 {
 	dev_dbg(&pdev->dev, "%s\n", __func__);
 
 	dfl_fpga_dev_ops_unregister(pdev);
 	dfl_fpga_dev_feature_uinit(pdev);
 	afu_dev_destroy(pdev);
-
-	return 0;
 }
 
 static const struct attribute_group *afu_dev_groups[] = {
@@ -956,7 +954,7 @@ static struct platform_driver afu_driver = {
 		.dev_groups = afu_dev_groups,
 	},
 	.probe   = afu_probe,
-	.remove  = afu_remove,
+	.remove_new = afu_remove,
 };
 
 static int __init afu_init(void)
-- 
2.42.0


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

* [PATCH 05/13] fpga: dfl-fme-br: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 04/13] fpga: dfl-afu-main: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 06/13] fpga: dfl-fme-main: " Uwe Kleine-König
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Wu Hao, Moritz Fischer, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/dfl-fme-br.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/dfl-fme-br.c b/drivers/fpga/dfl-fme-br.c
index 808d1f4d76df..0b01b3895277 100644
--- a/drivers/fpga/dfl-fme-br.c
+++ b/drivers/fpga/dfl-fme-br.c
@@ -78,7 +78,7 @@ static int fme_br_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int fme_br_remove(struct platform_device *pdev)
+static void fme_br_remove(struct platform_device *pdev)
 {
 	struct fpga_bridge *br = platform_get_drvdata(pdev);
 	struct fme_br_priv *priv = br->priv;
@@ -89,8 +89,6 @@ static int fme_br_remove(struct platform_device *pdev)
 		put_device(&priv->port_pdev->dev);
 	if (priv->port_ops)
 		dfl_fpga_port_ops_put(priv->port_ops);
-
-	return 0;
 }
 
 static struct platform_driver fme_br_driver = {
@@ -98,7 +96,7 @@ static struct platform_driver fme_br_driver = {
 		.name    = DFL_FPGA_FME_BRIDGE,
 	},
 	.probe   = fme_br_probe,
-	.remove  = fme_br_remove,
+	.remove_new = fme_br_remove,
 };
 
 module_platform_driver(fme_br_driver);
-- 
2.42.0


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

* [PATCH 06/13] fpga: dfl-fme-main: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 05/13] fpga: dfl-fme-br: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 07/13] fpga: dfl-fme-region: " Uwe Kleine-König
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Wu Hao, Moritz Fischer, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/dfl-fme-main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index 3dcf990bd261..a2b5da0093da 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -730,13 +730,11 @@ static int fme_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int fme_remove(struct platform_device *pdev)
+static void fme_remove(struct platform_device *pdev)
 {
 	dfl_fpga_dev_ops_unregister(pdev);
 	dfl_fpga_dev_feature_uinit(pdev);
 	fme_dev_destroy(pdev);
-
-	return 0;
 }
 
 static const struct attribute_group *fme_dev_groups[] = {
@@ -751,7 +749,7 @@ static struct platform_driver fme_driver = {
 		.dev_groups = fme_dev_groups,
 	},
 	.probe   = fme_probe,
-	.remove  = fme_remove,
+	.remove_new = fme_remove,
 };
 
 module_platform_driver(fme_driver);
-- 
2.42.0


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

* [PATCH 07/13] fpga: dfl-fme-region: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 06/13] fpga: dfl-fme-main: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 08/13] fpga: intel-m10-bmc-sec-update: " Uwe Kleine-König
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Wu Hao, Moritz Fischer, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/dfl-fme-region.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c
index 4aebde0a7f1c..71616f8b4982 100644
--- a/drivers/fpga/dfl-fme-region.c
+++ b/drivers/fpga/dfl-fme-region.c
@@ -61,15 +61,13 @@ static int fme_region_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int fme_region_remove(struct platform_device *pdev)
+static void fme_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = platform_get_drvdata(pdev);
 	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
-
-	return 0;
 }
 
 static struct platform_driver fme_region_driver = {
@@ -77,7 +75,7 @@ static struct platform_driver fme_region_driver = {
 		.name    = DFL_FPGA_FME_REGION,
 	},
 	.probe   = fme_region_probe,
-	.remove  = fme_region_remove,
+	.remove_new = fme_region_remove,
 };
 
 module_platform_driver(fme_region_driver);
-- 
2.42.0


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

* [PATCH 08/13] fpga: intel-m10-bmc-sec-update: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 07/13] fpga: dfl-fme-region: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 09/13] fpga: of-fpga-region: " Uwe Kleine-König
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun
  Cc: Peter Colberg, Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/intel-m10-bmc-sec-update.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c
index 31af2e08c825..89851b133709 100644
--- a/drivers/fpga/intel-m10-bmc-sec-update.c
+++ b/drivers/fpga/intel-m10-bmc-sec-update.c
@@ -730,15 +730,13 @@ static int m10bmc_sec_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int m10bmc_sec_remove(struct platform_device *pdev)
+static void m10bmc_sec_remove(struct platform_device *pdev)
 {
 	struct m10bmc_sec *sec = dev_get_drvdata(&pdev->dev);
 
 	firmware_upload_unregister(sec->fwl);
 	kfree(sec->fw_name);
 	xa_erase(&fw_upload_xa, sec->fw_name_id);
-
-	return 0;
 }
 
 static const struct platform_device_id intel_m10bmc_sec_ids[] = {
@@ -760,7 +758,7 @@ MODULE_DEVICE_TABLE(platform, intel_m10bmc_sec_ids);
 
 static struct platform_driver intel_m10bmc_sec_driver = {
 	.probe = m10bmc_sec_probe,
-	.remove = m10bmc_sec_remove,
+	.remove_new = m10bmc_sec_remove,
 	.driver = {
 		.name = "intel-m10bmc-sec-update",
 		.dev_groups = m10bmc_sec_attr_groups,
-- 
2.42.0


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

* [PATCH 09/13] fpga: of-fpga-region: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 08/13] fpga: intel-m10-bmc-sec-update: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 10/13] fpga: socfpga-a10: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/of-fpga-region.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index a6affd83f275..8526a5a86f0c 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -425,20 +425,18 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int of_fpga_region_remove(struct platform_device *pdev)
+static void of_fpga_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = platform_get_drvdata(pdev);
 	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
 	fpga_mgr_put(mgr);
-
-	return 0;
 }
 
 static struct platform_driver of_fpga_region_driver = {
 	.probe = of_fpga_region_probe,
-	.remove = of_fpga_region_remove,
+	.remove_new = of_fpga_region_remove,
 	.driver = {
 		.name	= "of-fpga-region",
 		.of_match_table = of_match_ptr(fpga_region_of_match),
-- 
2.42.0


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

* [PATCH 10/13] fpga: socfpga-a10: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 09/13] fpga: of-fpga-region: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 11/13] fpga: stratix10-soc: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/socfpga-a10.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c
index cc4861e345c9..4c03513b8f03 100644
--- a/drivers/fpga/socfpga-a10.c
+++ b/drivers/fpga/socfpga-a10.c
@@ -517,15 +517,13 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int socfpga_a10_fpga_remove(struct platform_device *pdev)
+static void socfpga_a10_fpga_remove(struct platform_device *pdev)
 {
 	struct fpga_manager *mgr = platform_get_drvdata(pdev);
 	struct a10_fpga_priv *priv = mgr->priv;
 
 	fpga_mgr_unregister(mgr);
 	clk_disable_unprepare(priv->clk);
-
-	return 0;
 }
 
 static const struct of_device_id socfpga_a10_fpga_of_match[] = {
@@ -537,7 +535,7 @@ MODULE_DEVICE_TABLE(of, socfpga_a10_fpga_of_match);
 
 static struct platform_driver socfpga_a10_fpga_driver = {
 	.probe = socfpga_a10_fpga_probe,
-	.remove = socfpga_a10_fpga_remove,
+	.remove_new = socfpga_a10_fpga_remove,
 	.driver = {
 		.name	= "socfpga_a10_fpga_manager",
 		.of_match_table = socfpga_a10_fpga_of_match,
-- 
2.42.0


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

* [PATCH 11/13] fpga: stratix10-soc: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 10/13] fpga: socfpga-a10: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 12/13] fpga: xilinx-pr-decoupler: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun; +Cc: Tom Rix, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/stratix10-soc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
index cacb9cc5757e..2c0def7d7cbb 100644
--- a/drivers/fpga/stratix10-soc.c
+++ b/drivers/fpga/stratix10-soc.c
@@ -436,15 +436,13 @@ static int s10_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int s10_remove(struct platform_device *pdev)
+static void s10_remove(struct platform_device *pdev)
 {
 	struct fpga_manager *mgr = platform_get_drvdata(pdev);
 	struct s10_priv *priv = mgr->priv;
 
 	fpga_mgr_unregister(mgr);
 	stratix10_svc_free_channel(priv->chan);
-
-	return 0;
 }
 
 static const struct of_device_id s10_of_match[] = {
@@ -457,7 +455,7 @@ MODULE_DEVICE_TABLE(of, s10_of_match);
 
 static struct platform_driver s10_driver = {
 	.probe = s10_probe,
-	.remove = s10_remove,
+	.remove_new = s10_remove,
 	.driver = {
 		.name	= "Stratix10 SoC FPGA manager",
 		.of_match_table = of_match_ptr(s10_of_match),
-- 
2.42.0


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

* [PATCH 12/13] fpga: xilinx-pr-decoupler: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (10 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 11/13] fpga: stratix10-soc: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-19 17:32 ` [PATCH 13/13] fpga: zynq-fpga: " Uwe Kleine-König
  2023-12-25  6:01 ` [PATCH 00/13] fpga: " Xu Yilun
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun
  Cc: Tom Rix, Michal Simek, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/xilinx-pr-decoupler.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/xilinx-pr-decoupler.c b/drivers/fpga/xilinx-pr-decoupler.c
index 68835896f180..788dd2f63a65 100644
--- a/drivers/fpga/xilinx-pr-decoupler.c
+++ b/drivers/fpga/xilinx-pr-decoupler.c
@@ -150,7 +150,7 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int xlnx_pr_decoupler_remove(struct platform_device *pdev)
+static void xlnx_pr_decoupler_remove(struct platform_device *pdev)
 {
 	struct fpga_bridge *bridge = platform_get_drvdata(pdev);
 	struct xlnx_pr_decoupler_data *p = bridge->priv;
@@ -158,13 +158,11 @@ static int xlnx_pr_decoupler_remove(struct platform_device *pdev)
 	fpga_bridge_unregister(bridge);
 
 	clk_unprepare(p->clk);
-
-	return 0;
 }
 
 static struct platform_driver xlnx_pr_decoupler_driver = {
 	.probe = xlnx_pr_decoupler_probe,
-	.remove = xlnx_pr_decoupler_remove,
+	.remove_new = xlnx_pr_decoupler_remove,
 	.driver = {
 		.name = "xlnx_pr_decoupler",
 		.of_match_table = xlnx_pr_decoupler_of_match,
-- 
2.42.0


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

* [PATCH 13/13] fpga: zynq-fpga: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (11 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 12/13] fpga: xilinx-pr-decoupler: " Uwe Kleine-König
@ 2023-12-19 17:32 ` Uwe Kleine-König
  2023-12-25  6:01 ` [PATCH 00/13] fpga: " Xu Yilun
  13 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-12-19 17:32 UTC (permalink / raw)
  To: Moritz Fischer, Wu Hao, Xu Yilun
  Cc: Tom Rix, Michal Simek, linux-fpga, 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

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/fpga/zynq-fpga.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
index 96611d424a10..0ac93183d201 100644
--- a/drivers/fpga/zynq-fpga.c
+++ b/drivers/fpga/zynq-fpga.c
@@ -618,7 +618,7 @@ static int zynq_fpga_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int zynq_fpga_remove(struct platform_device *pdev)
+static void zynq_fpga_remove(struct platform_device *pdev)
 {
 	struct zynq_fpga_priv *priv;
 	struct fpga_manager *mgr;
@@ -629,8 +629,6 @@ static int zynq_fpga_remove(struct platform_device *pdev)
 	fpga_mgr_unregister(mgr);
 
 	clk_unprepare(priv->clk);
-
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -644,7 +642,7 @@ MODULE_DEVICE_TABLE(of, zynq_fpga_of_match);
 
 static struct platform_driver zynq_fpga_driver = {
 	.probe = zynq_fpga_probe,
-	.remove = zynq_fpga_remove,
+	.remove_new = zynq_fpga_remove,
 	.driver = {
 		.name = "zynq_fpga_manager",
 		.of_match_table = of_match_ptr(zynq_fpga_of_match),
-- 
2.42.0


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

* Re: [PATCH 00/13] fpga: Convert to platform remove callback returning void
  2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (12 preceding siblings ...)
  2023-12-19 17:32 ` [PATCH 13/13] fpga: zynq-fpga: " Uwe Kleine-König
@ 2023-12-25  6:01 ` Xu Yilun
  13 siblings, 0 replies; 15+ messages in thread
From: Xu Yilun @ 2023-12-25  6:01 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Moritz Fischer, Wu Hao, Xu Yilun, Tom Rix, linux-fpga, kernel,
	Peter Colberg, Michal Simek, linux-arm-kernel

On Tue, Dec 19, 2023 at 06:31:58PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> this series converts all drivers below drivers/fpga to use
> .remove_new(). See commit 5c5a7680e67b ("platform: Provide a remove
> callback that returns no value") for an extended explanation and the
> eventual goal. The TL;DR; is to make it harder for driver authors to
> leak resources without noticing.
> 
> This is merge window material. All patches are pairwise independent of
> each other, so they could be applied individually. Getting them all in
> together would be nicer though :-)
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (13):
>   fpga: altera-fpga2sdram: Convert to platform remove callback returning void
>   fpga: altera-freeze-bridge: Convert to platform remove callback returning void
>   fpga: altera-hps2fpga: Convert to platform remove callback returning void
>   fpga: dfl-afu-main: Convert to platform remove callback returning void
>   fpga: dfl-fme-br: Convert to platform remove callback returning void
>   fpga: dfl-fme-main: Convert to platform remove callback returning void
>   fpga: dfl-fme-region: Convert to platform remove callback returning void
>   fpga: intel-m10-bmc-sec-update: Convert to platform remove callback returning void
>   fpga: of-fpga-region: Convert to platform remove callback returning void
>   fpga: socfpga-a10: Convert to platform remove callback returning void
>   fpga: stratix10-soc: Convert to platform remove callback returning void
>   fpga: xilinx-pr-decoupler: Convert to platform remove callback returning void
>   fpga: zynq-fpga: Convert to platform remove callback returning void
> 
>  drivers/fpga/altera-fpga2sdram.c        | 6 ++----
>  drivers/fpga/altera-freeze-bridge.c     | 6 ++----
>  drivers/fpga/altera-hps2fpga.c          | 6 ++----
>  drivers/fpga/dfl-afu-main.c             | 6 ++----
>  drivers/fpga/dfl-fme-br.c               | 6 ++----
>  drivers/fpga/dfl-fme-main.c             | 6 ++----
>  drivers/fpga/dfl-fme-region.c           | 6 ++----
>  drivers/fpga/intel-m10-bmc-sec-update.c | 6 ++----
>  drivers/fpga/of-fpga-region.c           | 6 ++----
>  drivers/fpga/socfpga-a10.c              | 6 ++----
>  drivers/fpga/stratix10-soc.c            | 6 ++----
>  drivers/fpga/xilinx-pr-decoupler.c      | 6 ++----
>  drivers/fpga/zynq-fpga.c                | 6 ++----
>  13 files changed, 26 insertions(+), 52 deletions(-)

Acked-by: Xu Yilun <yilun.xu@intel.com>

And applied this series to for-next for 6.8-rc1.

> 
> base-commit: aa4db8324c4d0e67aa4670356df4e9fae14b4d37
> -- 
> 2.42.0
> 
> 

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

end of thread, other threads:[~2023-12-25  6:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 17:31 [PATCH 00/13] fpga: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-19 17:31 ` [PATCH 01/13] fpga: altera-fpga2sdram: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 02/13] fpga: altera-freeze-bridge: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 03/13] fpga: altera-hps2fpga: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 04/13] fpga: dfl-afu-main: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 05/13] fpga: dfl-fme-br: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 06/13] fpga: dfl-fme-main: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 07/13] fpga: dfl-fme-region: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 08/13] fpga: intel-m10-bmc-sec-update: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 09/13] fpga: of-fpga-region: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 10/13] fpga: socfpga-a10: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 11/13] fpga: stratix10-soc: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 12/13] fpga: xilinx-pr-decoupler: " Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 13/13] fpga: zynq-fpga: " Uwe Kleine-König
2023-12-25  6:01 ` [PATCH 00/13] fpga: " Xu Yilun

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).