* [PATCH 00/13] fpga: Convert to platform remove callback returning void
@ 2023-12-19 17:31 Uwe Kleine-König
2023-12-19 17:32 ` [PATCH 12/13] fpga: xilinx-pr-decoupler: " Uwe Kleine-König
` (2 more replies)
0 siblings, 3 replies; 4+ 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ 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
@ 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
2 siblings, 0 replies; 4+ 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ 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
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
2 siblings, 0 replies; 4+ 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ 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
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 ` Xu Yilun
2 siblings, 0 replies; 4+ 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
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-25 6:05 UTC | newest]
Thread overview: 4+ 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: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