* [PATCH 00/12] mailbox: Convert to platform remove callback returning void
@ 2023-12-27 21:02 Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 03/12] mailbox: imx: " Uwe Kleine-König
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, Shawn Guo, Sascha Hauer, Fabio Estevam,
NXP Linux Team, linux-arm-kernel, Matthias Brugger,
AngeloGioacchino Del Regno, linux-mediatek, Bjorn Andersson,
Konrad Dybcio, linux-arm-msm, Manivannan Sadhasivam,
Maxime Coquelin, Alexandre Torgue, linux-stm32, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, linux-sunxi, Thierry Reding,
Jonathan Hunter, linux-tegra, Michal Simek, kernel
Hello,
this series converts all platform drivers below drivers/mailbox that
make use of .remove() to use .remove_new() instead.
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. The drivers here get it right though and so can be
converted trivially.
This is merge window material. All patches are pairwise independent, so
they can be applied individually.
Best regards
Uwe
Uwe Kleine-König (12):
mailbox: bcm-flexrm: Convert to platform remove callback returning void
mailbox: bcm-pdc: Convert to platform remove callback returning void
mailbox: imx: Convert to platform remove callback returning void
mailbox: mailbox-test: Convert to platform remove callback returning void
mailbox: mtk-cmdq: Convert to platform remove callback returning void
mailbox: omap: Convert to platform remove callback returning void
mailbox: qcom-apcs-ipc: Convert to platform remove callback returning void
mailbox: qcom-ipcc: Convert to platform remove callback returning void
mailbox: stm32-ipcc: Convert to platform remove callback returning void
mailbox: sun6i-msgbox: Convert to platform remove callback returning void
mailbox: tegra-hsp: Convert to platform remove callback returning void
mailbox: zynqmp-ipi: Convert to platform remove callback returning void
drivers/mailbox/bcm-flexrm-mailbox.c | 6 ++----
drivers/mailbox/bcm-pdc-mailbox.c | 5 ++---
drivers/mailbox/imx-mailbox.c | 6 ++----
drivers/mailbox/mailbox-test.c | 6 ++----
drivers/mailbox/mtk-cmdq-mailbox.c | 5 ++---
drivers/mailbox/omap-mailbox.c | 6 ++----
drivers/mailbox/qcom-apcs-ipc-mailbox.c | 6 ++----
drivers/mailbox/qcom-ipcc.c | 6 ++----
drivers/mailbox/stm32-ipcc.c | 6 ++----
drivers/mailbox/sun6i-msgbox.c | 6 ++----
drivers/mailbox/tegra-hsp.c | 6 ++----
drivers/mailbox/zynqmp-ipi-mailbox.c | 6 ++----
12 files changed, 24 insertions(+), 46 deletions(-)
base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
--
2.43.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] 8+ messages in thread
* [PATCH 03/12] mailbox: imx: Convert to platform remove callback returning void
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-12-27 21:02 ` Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 05/12] mailbox: mtk-cmdq: " Uwe Kleine-König
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar
Cc: Shawn Guo, Sascha Hauer, Fabio Estevam, NXP Linux Team,
linux-kernel, 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/mailbox/imx-mailbox.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
index 0af739ab571c..656171362fe9 100644
--- a/drivers/mailbox/imx-mailbox.c
+++ b/drivers/mailbox/imx-mailbox.c
@@ -903,13 +903,11 @@ static int imx_mu_probe(struct platform_device *pdev)
return ret;
}
-static int imx_mu_remove(struct platform_device *pdev)
+static void imx_mu_remove(struct platform_device *pdev)
{
struct imx_mu_priv *priv = platform_get_drvdata(pdev);
pm_runtime_disable(priv->dev);
-
- return 0;
}
static const struct imx_mu_dcfg imx_mu_cfg_imx6sx = {
@@ -1070,7 +1068,7 @@ static const struct dev_pm_ops imx_mu_pm_ops = {
static struct platform_driver imx_mu_driver = {
.probe = imx_mu_probe,
- .remove = imx_mu_remove,
+ .remove_new = imx_mu_remove,
.driver = {
.name = "imx_mu",
.of_match_table = imx_mu_dt_ids,
--
2.43.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] 8+ messages in thread
* [PATCH 05/12] mailbox: mtk-cmdq: Convert to platform remove callback returning void
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 03/12] mailbox: imx: " Uwe Kleine-König
@ 2023-12-27 21:02 ` Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 09/12] mailbox: stm32-ipcc: " Uwe Kleine-König
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar
Cc: Matthias Brugger, AngeloGioacchino Del Regno, linux-kernel,
linux-arm-kernel, linux-mediatek, 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/mailbox/mtk-cmdq-mailbox.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index de862e9137d5..c9009b729ab2 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -367,7 +367,7 @@ static int cmdq_resume(struct device *dev)
return 0;
}
-static int cmdq_remove(struct platform_device *pdev)
+static void cmdq_remove(struct platform_device *pdev)
{
struct cmdq *cmdq = platform_get_drvdata(pdev);
@@ -378,7 +378,6 @@ static int cmdq_remove(struct platform_device *pdev)
cmdq_runtime_suspend(&pdev->dev);
clk_bulk_unprepare(cmdq->pdata->gce_num, cmdq->clocks);
- return 0;
}
static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
@@ -761,7 +760,7 @@ static const struct of_device_id cmdq_of_ids[] = {
static struct platform_driver cmdq_drv = {
.probe = cmdq_probe,
- .remove = cmdq_remove,
+ .remove_new = cmdq_remove,
.driver = {
.name = "mtk_cmdq",
.pm = &cmdq_pm_ops,
--
2.43.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] 8+ messages in thread
* [PATCH 09/12] mailbox: stm32-ipcc: Convert to platform remove callback returning void
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 03/12] mailbox: imx: " Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 05/12] mailbox: mtk-cmdq: " Uwe Kleine-König
@ 2023-12-27 21:02 ` Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 10/12] mailbox: sun6i-msgbox: " Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 12/12] mailbox: zynqmp-ipi: " Uwe Kleine-König
4 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar
Cc: Maxime Coquelin, Alexandre Torgue, linux-kernel, 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 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/mailbox/stm32-ipcc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
index 4ad3653f3866..1442f275782b 100644
--- a/drivers/mailbox/stm32-ipcc.c
+++ b/drivers/mailbox/stm32-ipcc.c
@@ -331,7 +331,7 @@ static int stm32_ipcc_probe(struct platform_device *pdev)
return ret;
}
-static int stm32_ipcc_remove(struct platform_device *pdev)
+static void stm32_ipcc_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -339,8 +339,6 @@ static int stm32_ipcc_remove(struct platform_device *pdev)
dev_pm_clear_wake_irq(&pdev->dev);
device_set_wakeup_capable(dev, false);
-
- return 0;
}
#ifdef CONFIG_PM_SLEEP
@@ -381,7 +379,7 @@ static struct platform_driver stm32_ipcc_driver = {
.of_match_table = stm32_ipcc_of_match,
},
.probe = stm32_ipcc_probe,
- .remove = stm32_ipcc_remove,
+ .remove_new = stm32_ipcc_remove,
};
module_platform_driver(stm32_ipcc_driver);
--
2.43.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] 8+ messages in thread
* [PATCH 10/12] mailbox: sun6i-msgbox: Convert to platform remove callback returning void
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
` (2 preceding siblings ...)
2023-12-27 21:02 ` [PATCH 09/12] mailbox: stm32-ipcc: " Uwe Kleine-König
@ 2023-12-27 21:02 ` Uwe Kleine-König
2024-01-09 20:15 ` Jernej Škrabec
2023-12-27 21:02 ` [PATCH 12/12] mailbox: zynqmp-ipi: " Uwe Kleine-König
4 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar
Cc: Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, linux-kernel,
linux-arm-kernel, linux-sunxi, 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/mailbox/sun6i-msgbox.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c
index 7f8d931042d3..3dcc54dc83b2 100644
--- a/drivers/mailbox/sun6i-msgbox.c
+++ b/drivers/mailbox/sun6i-msgbox.c
@@ -287,15 +287,13 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
return ret;
}
-static int sun6i_msgbox_remove(struct platform_device *pdev)
+static void sun6i_msgbox_remove(struct platform_device *pdev)
{
struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
mbox_controller_unregister(&mbox->controller);
/* See the comment in sun6i_msgbox_probe about the reset line. */
clk_disable_unprepare(mbox->clk);
-
- return 0;
}
static const struct of_device_id sun6i_msgbox_of_match[] = {
@@ -310,7 +308,7 @@ static struct platform_driver sun6i_msgbox_driver = {
.of_match_table = sun6i_msgbox_of_match,
},
.probe = sun6i_msgbox_probe,
- .remove = sun6i_msgbox_remove,
+ .remove_new = sun6i_msgbox_remove,
};
module_platform_driver(sun6i_msgbox_driver);
--
2.43.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] 8+ messages in thread
* [PATCH 12/12] mailbox: zynqmp-ipi: Convert to platform remove callback returning void
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
` (3 preceding siblings ...)
2023-12-27 21:02 ` [PATCH 10/12] mailbox: sun6i-msgbox: " Uwe Kleine-König
@ 2023-12-27 21:02 ` Uwe Kleine-König
2024-01-02 9:36 ` Michal Simek
4 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 21:02 UTC (permalink / raw)
To: Jassi Brar; +Cc: Michal Simek, linux-kernel, 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/mailbox/zynqmp-ipi-mailbox.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
index 7fa533e80dd9..610a92f9c0b2 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -688,19 +688,17 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
return ret;
}
-static int zynqmp_ipi_remove(struct platform_device *pdev)
+static void zynqmp_ipi_remove(struct platform_device *pdev)
{
struct zynqmp_ipi_pdata *pdata;
pdata = platform_get_drvdata(pdev);
zynqmp_ipi_free_mboxes(pdata);
-
- return 0;
}
static struct platform_driver zynqmp_ipi_driver = {
.probe = zynqmp_ipi_probe,
- .remove = zynqmp_ipi_remove,
+ .remove_new = zynqmp_ipi_remove,
.driver = {
.name = "zynqmp-ipi",
.of_match_table = of_match_ptr(zynqmp_ipi_of_match),
--
2.43.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] 8+ messages in thread
* Re: [PATCH 12/12] mailbox: zynqmp-ipi: Convert to platform remove callback returning void
2023-12-27 21:02 ` [PATCH 12/12] mailbox: zynqmp-ipi: " Uwe Kleine-König
@ 2024-01-02 9:36 ` Michal Simek
0 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2024-01-02 9:36 UTC (permalink / raw)
To: Uwe Kleine-König, Jassi Brar; +Cc: linux-kernel, linux-arm-kernel, kernel
On 12/27/23 22:02, 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 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/mailbox/zynqmp-ipi-mailbox.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
> index 7fa533e80dd9..610a92f9c0b2 100644
> --- a/drivers/mailbox/zynqmp-ipi-mailbox.c
> +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
> @@ -688,19 +688,17 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int zynqmp_ipi_remove(struct platform_device *pdev)
> +static void zynqmp_ipi_remove(struct platform_device *pdev)
> {
> struct zynqmp_ipi_pdata *pdata;
>
> pdata = platform_get_drvdata(pdev);
> zynqmp_ipi_free_mboxes(pdata);
> -
> - return 0;
> }
>
> static struct platform_driver zynqmp_ipi_driver = {
> .probe = zynqmp_ipi_probe,
> - .remove = zynqmp_ipi_remove,
> + .remove_new = zynqmp_ipi_remove,
> .driver = {
> .name = "zynqmp-ipi",
> .of_match_table = of_match_ptr(zynqmp_ipi_of_match),
Reviewed-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
_______________________________________________
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] 8+ messages in thread
* Re: [PATCH 10/12] mailbox: sun6i-msgbox: Convert to platform remove callback returning void
2023-12-27 21:02 ` [PATCH 10/12] mailbox: sun6i-msgbox: " Uwe Kleine-König
@ 2024-01-09 20:15 ` Jernej Škrabec
0 siblings, 0 replies; 8+ messages in thread
From: Jernej Škrabec @ 2024-01-09 20:15 UTC (permalink / raw)
To: Jassi Brar, Uwe Kleine-König
Cc: Chen-Yu Tsai, Samuel Holland, linux-kernel, linux-arm-kernel,
linux-sunxi, kernel
Dne sreda, 27. december 2023 ob 22:02:38 CET 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 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>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
_______________________________________________
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] 8+ messages in thread
end of thread, other threads:[~2024-01-09 20:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27 21:02 [PATCH 00/12] mailbox: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 03/12] mailbox: imx: " Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 05/12] mailbox: mtk-cmdq: " Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 09/12] mailbox: stm32-ipcc: " Uwe Kleine-König
2023-12-27 21:02 ` [PATCH 10/12] mailbox: sun6i-msgbox: " Uwe Kleine-König
2024-01-09 20:15 ` Jernej Škrabec
2023-12-27 21:02 ` [PATCH 12/12] mailbox: zynqmp-ipi: " Uwe Kleine-König
2024-01-02 9:36 ` Michal Simek
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).