* [PATCH 00/11] firmware: Convert to platform remove callback returning void
@ 2023-12-27 16:26 Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 01/11] firmware: arm_scmi: " Uwe Kleine-König
` (10 more replies)
0 siblings, 11 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Sudeep Holla, Tzung-Bi Shih, Shawn Guo, Sascha Hauer,
Daniel Baluta, Thierry Reding, Hao Ge, Rob Herring,
Christophe JAILLET, Matthias Brugger, AngeloGioacchino Del Regno,
Arnd Bergmann, Gabriel Somlo, Michael S. Tsirkin,
Florian Fainelli, Kieran Bingham, Dinh Nguyen, Marek Behún,
Michal Simek, Greg Kroah-Hartman, Jay Buddhabhatti,
Sai Krishna Potthuri, Linus Walleij, Nava kishore Manne,
Rajan Vaja, Dhaval Shah, Marek Vasut
Cc: kernel, Cristian Marussi, linux-arm-kernel, linux-kernel,
Brian Norris, Julius Werner, chrome-platform, Fabio Estevam,
NXP Linux Team, linux-mediatek, qemu-devel,
Broadcom internal kernel review list, linux-rpi-kernel
Hello,
this series converts all platform drivers below drivers/firmware 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. There doesn't seem to be a maintainer for
all of drivers/firmware and I don't know how patch application works
there usually. All patches are pairwise independent, so they can be
applied individually.
Best regards
Uwe
Uwe Kleine-König (11):
firmware: arm_scmi: Convert to platform remove callback returning void
firmware: arm_scpi: Convert to platform remove callback returning void
firmware: coreboot_table: Convert to platform remove callback returning void
firmware: imx-dsp: Convert to platform remove callback returning void
firmware: mtk-adsp-ipc: Convert to platform remove callback returning void
firmware: qemu_fw_cfg: Convert to platform remove callback returning void
firmware: raspberrypi: Convert to platform remove callback returning void
firmware: stratix10-rsu: Convert to platform remove callback returning void
firmware: stratix10-svc: Convert to platform remove callback returning void
firmware: turris-mox-rwtm: Convert to platform remove callback returning void
firmware: zynqmp: Convert to platform remove callback returning void
drivers/firmware/arm_scmi/driver.c | 6 ++----
drivers/firmware/arm_scpi.c | 6 ++----
drivers/firmware/google/coreboot_table.c | 5 ++---
drivers/firmware/imx/imx-dsp.c | 6 ++----
drivers/firmware/mtk-adsp-ipc.c | 6 ++----
drivers/firmware/qemu_fw_cfg.c | 5 ++---
drivers/firmware/raspberrypi.c | 6 ++----
drivers/firmware/stratix10-rsu.c | 5 ++---
drivers/firmware/stratix10-svc.c | 6 ++----
drivers/firmware/turris-mox-rwtm.c | 6 ++----
drivers/firmware/xilinx/zynqmp.c | 6 ++----
11 files changed, 22 insertions(+), 41 deletions(-)
base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 01/11] firmware: arm_scmi: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 02/11] firmware: arm_scpi: " Uwe Kleine-König
` (9 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Sudeep Holla; +Cc: kernel, Cristian Marussi, linux-arm-kernel, linux-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/firmware/arm_scmi/driver.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index a9f70e6e58ac..3ea64b22cf0d 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2834,7 +2834,7 @@ static int scmi_probe(struct platform_device *pdev)
return ret;
}
-static int scmi_remove(struct platform_device *pdev)
+static void scmi_remove(struct platform_device *pdev)
{
int id;
struct scmi_info *info = platform_get_drvdata(pdev);
@@ -2868,8 +2868,6 @@ static int scmi_remove(struct platform_device *pdev)
scmi_cleanup_txrx_channels(info);
ida_free(&scmi_id, info->id);
-
- return 0;
}
static ssize_t protocol_version_show(struct device *dev,
@@ -2947,7 +2945,7 @@ static struct platform_driver scmi_driver = {
.dev_groups = versions_groups,
},
.probe = scmi_probe,
- .remove = scmi_remove,
+ .remove_new = scmi_remove,
};
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/11] firmware: arm_scpi: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 01/11] firmware: arm_scmi: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 03/11] firmware: coreboot_table: " Uwe Kleine-König
` (8 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Sudeep Holla; +Cc: kernel, Cristian Marussi, linux-arm-kernel, linux-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/firmware/arm_scpi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 3f123f592cb4..94a6b4e667de 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -863,7 +863,7 @@ static void scpi_free_channels(void *data)
mbox_free_channel(info->channels[i].chan);
}
-static int scpi_remove(struct platform_device *pdev)
+static void scpi_remove(struct platform_device *pdev)
{
int i;
struct scpi_drvinfo *info = platform_get_drvdata(pdev);
@@ -874,8 +874,6 @@ static int scpi_remove(struct platform_device *pdev)
kfree(info->dvfs[i]->opps);
kfree(info->dvfs[i]);
}
-
- return 0;
}
#define MAX_SCPI_XFERS 10
@@ -1048,7 +1046,7 @@ static struct platform_driver scpi_driver = {
.dev_groups = versions_groups,
},
.probe = scpi_probe,
- .remove = scpi_remove,
+ .remove_new = scpi_remove,
};
module_platform_driver(scpi_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/11] firmware: coreboot_table: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 01/11] firmware: arm_scmi: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 02/11] firmware: arm_scpi: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-28 3:12 ` Tzung-Bi Shih
2023-12-27 16:26 ` [PATCH 04/11] firmware: imx-dsp: " Uwe Kleine-König
` (7 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: kernel, Brian Norris, Julius Werner, chrome-platform,
linux-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/firmware/google/coreboot_table.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index 33ae94745aef..2a4469bf1b81 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -176,10 +176,9 @@ static int __cb_dev_unregister(struct device *dev, void *dummy)
return 0;
}
-static int coreboot_table_remove(struct platform_device *pdev)
+static void coreboot_table_remove(struct platform_device *pdev)
{
bus_for_each_dev(&coreboot_bus_type, NULL, NULL, __cb_dev_unregister);
- return 0;
}
#ifdef CONFIG_ACPI
@@ -201,7 +200,7 @@ MODULE_DEVICE_TABLE(of, coreboot_of_match);
static struct platform_driver coreboot_table_driver = {
.probe = coreboot_table_probe,
- .remove = coreboot_table_remove,
+ .remove_new = coreboot_table_remove,
.driver = {
.name = "coreboot_table",
.acpi_match_table = ACPI_PTR(cros_coreboot_acpi_match),
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/11] firmware: imx-dsp: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (2 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 03/11] firmware: coreboot_table: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 05/11] firmware: mtk-adsp-ipc: " Uwe Kleine-König
` (6 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Daniel Baluta, Thierry Reding,
Sudeep Holla, Hao Ge, Rob Herring, Christophe JAILLET
Cc: kernel, Fabio Estevam, NXP Linux Team, linux-arm-kernel,
linux-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/firmware/imx/imx-dsp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/imx/imx-dsp.c b/drivers/firmware/imx/imx-dsp.c
index a48a58e0c61f..01c8ef14eaec 100644
--- a/drivers/firmware/imx/imx-dsp.c
+++ b/drivers/firmware/imx/imx-dsp.c
@@ -160,7 +160,7 @@ static int imx_dsp_probe(struct platform_device *pdev)
return 0;
}
-static int imx_dsp_remove(struct platform_device *pdev)
+static void imx_dsp_remove(struct platform_device *pdev)
{
struct imx_dsp_chan *dsp_chan;
struct imx_dsp_ipc *dsp_ipc;
@@ -173,8 +173,6 @@ static int imx_dsp_remove(struct platform_device *pdev)
mbox_free_channel(dsp_chan->ch);
kfree(dsp_chan->name);
}
-
- return 0;
}
static struct platform_driver imx_dsp_driver = {
@@ -182,7 +180,7 @@ static struct platform_driver imx_dsp_driver = {
.name = "imx-dsp",
},
.probe = imx_dsp_probe,
- .remove = imx_dsp_remove,
+ .remove_new = imx_dsp_remove,
};
builtin_platform_driver(imx_dsp_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/11] firmware: mtk-adsp-ipc: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (3 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 04/11] firmware: imx-dsp: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
` (5 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Matthias Brugger, AngeloGioacchino Del Regno, Thierry Reding,
Rob Herring, Arnd Bergmann, Sudeep Holla
Cc: kernel, linux-kernel, linux-arm-kernel, linux-mediatek
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/firmware/mtk-adsp-ipc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/mtk-adsp-ipc.c b/drivers/firmware/mtk-adsp-ipc.c
index 85e94ddc7204..a762302978de 100644
--- a/drivers/firmware/mtk-adsp-ipc.c
+++ b/drivers/firmware/mtk-adsp-ipc.c
@@ -116,7 +116,7 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
return 0;
}
-static int mtk_adsp_ipc_remove(struct platform_device *pdev)
+static void mtk_adsp_ipc_remove(struct platform_device *pdev)
{
struct mtk_adsp_ipc *adsp_ipc = dev_get_drvdata(&pdev->dev);
struct mtk_adsp_chan *adsp_chan;
@@ -126,8 +126,6 @@ static int mtk_adsp_ipc_remove(struct platform_device *pdev)
adsp_chan = &adsp_ipc->chans[i];
mbox_free_channel(adsp_chan->ch);
}
-
- return 0;
}
static struct platform_driver mtk_adsp_ipc_driver = {
@@ -135,7 +133,7 @@ static struct platform_driver mtk_adsp_ipc_driver = {
.name = "mtk-adsp-ipc",
},
.probe = mtk_adsp_ipc_probe,
- .remove = mtk_adsp_ipc_remove,
+ .remove_new = mtk_adsp_ipc_remove,
};
builtin_platform_driver(mtk_adsp_ipc_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (4 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 05/11] firmware: mtk-adsp-ipc: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 17:07 ` Philippe Mathieu-Daudé
2023-12-27 20:46 ` Michael S. Tsirkin
2023-12-27 16:26 ` [PATCH 07/11] firmware: raspberrypi: " Uwe Kleine-König
` (4 subsequent siblings)
10 siblings, 2 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Gabriel Somlo, Michael S. Tsirkin; +Cc: kernel, qemu-devel, linux-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/firmware/qemu_fw_cfg.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 1448f61173b3..03da9a4354f8 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -731,7 +731,7 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
return err;
}
-static int fw_cfg_sysfs_remove(struct platform_device *pdev)
+static void fw_cfg_sysfs_remove(struct platform_device *pdev)
{
pr_debug("fw_cfg: unloading.\n");
fw_cfg_sysfs_cache_cleanup();
@@ -739,7 +739,6 @@ static int fw_cfg_sysfs_remove(struct platform_device *pdev)
fw_cfg_io_cleanup();
fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
- return 0;
}
static const struct of_device_id fw_cfg_sysfs_mmio_match[] = {
@@ -758,7 +757,7 @@ MODULE_DEVICE_TABLE(acpi, fw_cfg_sysfs_acpi_match);
static struct platform_driver fw_cfg_sysfs_driver = {
.probe = fw_cfg_sysfs_probe,
- .remove = fw_cfg_sysfs_remove,
+ .remove_new = fw_cfg_sysfs_remove,
.driver = {
.name = "fw_cfg",
.of_match_table = fw_cfg_sysfs_mmio_match,
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/11] firmware: raspberrypi: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (5 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-27 16:43 ` Florian Fainelli
2023-12-27 16:26 ` [PATCH 08/11] firmware: stratix10-rsu: " Uwe Kleine-König
` (3 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Florian Fainelli, Kieran Bingham, Arnd Bergmann, Rob Herring
Cc: kernel, Broadcom internal kernel review list, linux-rpi-kernel,
linux-arm-kernel, linux-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/firmware/raspberrypi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 4cd290a60fba..322aada20f74 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -317,7 +317,7 @@ static void rpi_firmware_shutdown(struct platform_device *pdev)
rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_REBOOT, NULL, 0);
}
-static int rpi_firmware_remove(struct platform_device *pdev)
+static void rpi_firmware_remove(struct platform_device *pdev)
{
struct rpi_firmware *fw = platform_get_drvdata(pdev);
@@ -327,8 +327,6 @@ static int rpi_firmware_remove(struct platform_device *pdev)
rpi_clk = NULL;
rpi_firmware_put(fw);
-
- return 0;
}
static const struct of_device_id rpi_firmware_of_match[] = {
@@ -406,7 +404,7 @@ static struct platform_driver rpi_firmware_driver = {
},
.probe = rpi_firmware_probe,
.shutdown = rpi_firmware_shutdown,
- .remove = rpi_firmware_remove,
+ .remove_new = rpi_firmware_remove,
};
module_platform_driver(rpi_firmware_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/11] firmware: stratix10-rsu: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (6 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 07/11] firmware: raspberrypi: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2024-01-04 12:22 ` Dinh Nguyen
2023-12-27 16:26 ` [PATCH 09/11] firmware: stratix10-svc: " Uwe Kleine-König
` (2 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Dinh Nguyen; +Cc: kernel, linux-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/firmware/stratix10-rsu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
index 4f7a7abada48..e20cee9c2d32 100644
--- a/drivers/firmware/stratix10-rsu.c
+++ b/drivers/firmware/stratix10-rsu.c
@@ -793,17 +793,16 @@ static int stratix10_rsu_probe(struct platform_device *pdev)
return ret;
}
-static int stratix10_rsu_remove(struct platform_device *pdev)
+static void stratix10_rsu_remove(struct platform_device *pdev)
{
struct stratix10_rsu_priv *priv = platform_get_drvdata(pdev);
stratix10_svc_free_channel(priv->chan);
- return 0;
}
static struct platform_driver stratix10_rsu_driver = {
.probe = stratix10_rsu_probe,
- .remove = stratix10_rsu_remove,
+ .remove_new = stratix10_rsu_remove,
.driver = {
.name = "stratix10-rsu",
.dev_groups = rsu_groups,
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/11] firmware: stratix10-svc: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (7 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 08/11] firmware: stratix10-rsu: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2024-01-04 12:22 ` Dinh Nguyen
2023-12-27 16:26 ` [PATCH 10/11] firmware: turris-mox-rwtm: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 11/11] firmware: zynqmp: " Uwe Kleine-König
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Dinh Nguyen; +Cc: kernel, linux-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/firmware/stratix10-svc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index c693da60e9a9..528f37417aea 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1251,7 +1251,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
return ret;
}
-static int stratix10_svc_drv_remove(struct platform_device *pdev)
+static void stratix10_svc_drv_remove(struct platform_device *pdev)
{
struct stratix10_svc *svc = dev_get_drvdata(&pdev->dev);
struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
@@ -1267,13 +1267,11 @@ static int stratix10_svc_drv_remove(struct platform_device *pdev)
if (ctrl->genpool)
gen_pool_destroy(ctrl->genpool);
list_del(&ctrl->node);
-
- return 0;
}
static struct platform_driver stratix10_svc_driver = {
.probe = stratix10_svc_drv_probe,
- .remove = stratix10_svc_drv_remove,
+ .remove_new = stratix10_svc_drv_remove,
.driver = {
.name = "stratix10-svc",
.of_match_table = stratix10_svc_drv_match,
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 10/11] firmware: turris-mox-rwtm: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (8 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 09/11] firmware: stratix10-svc: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2023-12-28 15:32 ` Marek Behún
2023-12-27 16:26 ` [PATCH 11/11] firmware: zynqmp: " Uwe Kleine-König
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Marek Behún; +Cc: kernel, linux-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/firmware/turris-mox-rwtm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 2de0fb139ce1..31d962cdd6eb 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -554,7 +554,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
return ret;
}
-static int turris_mox_rwtm_remove(struct platform_device *pdev)
+static void turris_mox_rwtm_remove(struct platform_device *pdev)
{
struct mox_rwtm *rwtm = platform_get_drvdata(pdev);
@@ -562,8 +562,6 @@ static int turris_mox_rwtm_remove(struct platform_device *pdev)
sysfs_remove_files(rwtm_to_kobj(rwtm), mox_rwtm_attrs);
kobject_put(rwtm_to_kobj(rwtm));
mbox_free_channel(rwtm->mbox);
-
- return 0;
}
static const struct of_device_id turris_mox_rwtm_match[] = {
@@ -576,7 +574,7 @@ MODULE_DEVICE_TABLE(of, turris_mox_rwtm_match);
static struct platform_driver turris_mox_rwtm_driver = {
.probe = turris_mox_rwtm_probe,
- .remove = turris_mox_rwtm_remove,
+ .remove_new = turris_mox_rwtm_remove,
.driver = {
.name = DRIVER_NAME,
.of_match_table = turris_mox_rwtm_match,
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 11/11] firmware: zynqmp: Convert to platform remove callback returning void
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
` (9 preceding siblings ...)
2023-12-27 16:26 ` [PATCH 10/11] firmware: turris-mox-rwtm: " Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
2024-01-02 10:00 ` Michal Simek
10 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
To: Michal Simek, Greg Kroah-Hartman, Jay Buddhabhatti,
Sai Krishna Potthuri, Linus Walleij, Nava kishore Manne,
Rajan Vaja, Rob Herring, Dhaval Shah, Marek Vasut
Cc: kernel, linux-arm-kernel, linux-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/firmware/xilinx/zynqmp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index a55dfd9bae6b..73cae6ef83ec 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1929,7 +1929,7 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
return of_platform_populate(dev->of_node, NULL, NULL, dev);
}
-static int zynqmp_firmware_remove(struct platform_device *pdev)
+static void zynqmp_firmware_remove(struct platform_device *pdev)
{
struct pm_api_feature_data *feature_data;
struct hlist_node *tmp;
@@ -1944,8 +1944,6 @@ static int zynqmp_firmware_remove(struct platform_device *pdev)
}
platform_device_unregister(em_dev);
-
- return 0;
}
static const struct of_device_id zynqmp_firmware_of_match[] = {
@@ -1962,6 +1960,6 @@ static struct platform_driver zynqmp_firmware_driver = {
.dev_groups = zynqmp_firmware_groups,
},
.probe = zynqmp_firmware_probe,
- .remove = zynqmp_firmware_remove,
+ .remove_new = zynqmp_firmware_remove,
};
module_platform_driver(zynqmp_firmware_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 07/11] firmware: raspberrypi: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 07/11] firmware: raspberrypi: " Uwe Kleine-König
@ 2023-12-27 16:43 ` Florian Fainelli
0 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2023-12-27 16:43 UTC (permalink / raw)
To: Uwe Kleine-König, Kieran Bingham, Arnd Bergmann, Rob Herring
Cc: kernel, Broadcom internal kernel review list, linux-rpi-kernel,
linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 885 bytes --]
On 12/27/2023 5:26 PM, 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>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
@ 2023-12-27 17:07 ` Philippe Mathieu-Daudé
2023-12-27 20:46 ` Michael S. Tsirkin
1 sibling, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-27 17:07 UTC (permalink / raw)
To: Uwe Kleine-König, Gabriel Somlo, Michael S. Tsirkin
Cc: kernel, qemu-devel, linux-kernel
On 27/12/23 17:26, 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/firmware/qemu_fw_cfg.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
2023-12-27 17:07 ` Philippe Mathieu-Daudé
@ 2023-12-27 20:46 ` Michael S. Tsirkin
1 sibling, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2023-12-27 20:46 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Gabriel Somlo, kernel, qemu-devel, linux-kernel
On Wed, Dec 27, 2023 at 05:26:30PM +0100, 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>
I don't mind.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/firmware/qemu_fw_cfg.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 1448f61173b3..03da9a4354f8 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -731,7 +731,7 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
> return err;
> }
>
> -static int fw_cfg_sysfs_remove(struct platform_device *pdev)
> +static void fw_cfg_sysfs_remove(struct platform_device *pdev)
> {
> pr_debug("fw_cfg: unloading.\n");
> fw_cfg_sysfs_cache_cleanup();
> @@ -739,7 +739,6 @@ static int fw_cfg_sysfs_remove(struct platform_device *pdev)
> fw_cfg_io_cleanup();
> fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
> fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
> - return 0;
> }
>
> static const struct of_device_id fw_cfg_sysfs_mmio_match[] = {
> @@ -758,7 +757,7 @@ MODULE_DEVICE_TABLE(acpi, fw_cfg_sysfs_acpi_match);
>
> static struct platform_driver fw_cfg_sysfs_driver = {
> .probe = fw_cfg_sysfs_probe,
> - .remove = fw_cfg_sysfs_remove,
> + .remove_new = fw_cfg_sysfs_remove,
> .driver = {
> .name = "fw_cfg",
> .of_match_table = fw_cfg_sysfs_mmio_match,
> --
> 2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 03/11] firmware: coreboot_table: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 03/11] firmware: coreboot_table: " Uwe Kleine-König
@ 2023-12-28 3:12 ` Tzung-Bi Shih
0 siblings, 0 replies; 20+ messages in thread
From: Tzung-Bi Shih @ 2023-12-28 3:12 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: kernel, Brian Norris, Julius Werner, chrome-platform,
linux-kernel
On Wed, Dec 27, 2023 at 05:26:27PM +0100, 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().
>
> [...]
Applied, thanks!
[03/11] firmware: coreboot: Convert to platform remove callback returning void
commit: 09aeaabebdafbcf4afd1c481beaff37ecbc6b023
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 10/11] firmware: turris-mox-rwtm: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 10/11] firmware: turris-mox-rwtm: " Uwe Kleine-König
@ 2023-12-28 15:32 ` Marek Behún
0 siblings, 0 replies; 20+ messages in thread
From: Marek Behún @ 2023-12-28 15:32 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: kernel, linux-kernel
On Wed, 27 Dec 2023 17:26:34 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> 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/firmware/turris-mox-rwtm.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
> index 2de0fb139ce1..31d962cdd6eb 100644
> --- a/drivers/firmware/turris-mox-rwtm.c
> +++ b/drivers/firmware/turris-mox-rwtm.c
> @@ -554,7 +554,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int turris_mox_rwtm_remove(struct platform_device *pdev)
> +static void turris_mox_rwtm_remove(struct platform_device *pdev)
> {
> struct mox_rwtm *rwtm = platform_get_drvdata(pdev);
>
> @@ -562,8 +562,6 @@ static int turris_mox_rwtm_remove(struct platform_device *pdev)
> sysfs_remove_files(rwtm_to_kobj(rwtm), mox_rwtm_attrs);
> kobject_put(rwtm_to_kobj(rwtm));
> mbox_free_channel(rwtm->mbox);
> -
> - return 0;
> }
>
> static const struct of_device_id turris_mox_rwtm_match[] = {
> @@ -576,7 +574,7 @@ MODULE_DEVICE_TABLE(of, turris_mox_rwtm_match);
>
> static struct platform_driver turris_mox_rwtm_driver = {
> .probe = turris_mox_rwtm_probe,
> - .remove = turris_mox_rwtm_remove,
> + .remove_new = turris_mox_rwtm_remove,
> .driver = {
> .name = DRIVER_NAME,
> .of_match_table = turris_mox_rwtm_match,
Reviewed-by: Marek Behún <kabel@kernel.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 11/11] firmware: zynqmp: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 11/11] firmware: zynqmp: " Uwe Kleine-König
@ 2024-01-02 10:00 ` Michal Simek
0 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2024-01-02 10:00 UTC (permalink / raw)
To: Uwe Kleine-König, Greg Kroah-Hartman, Jay Buddhabhatti,
Sai Krishna Potthuri, Linus Walleij, Nava kishore Manne,
Rajan Vaja, Rob Herring, Dhaval Shah, Marek Vasut
Cc: kernel, linux-arm-kernel, linux-kernel
On 12/27/23 17:26, 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/firmware/xilinx/zynqmp.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index a55dfd9bae6b..73cae6ef83ec 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -1929,7 +1929,7 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
> return of_platform_populate(dev->of_node, NULL, NULL, dev);
> }
>
> -static int zynqmp_firmware_remove(struct platform_device *pdev)
> +static void zynqmp_firmware_remove(struct platform_device *pdev)
> {
> struct pm_api_feature_data *feature_data;
> struct hlist_node *tmp;
> @@ -1944,8 +1944,6 @@ static int zynqmp_firmware_remove(struct platform_device *pdev)
> }
>
> platform_device_unregister(em_dev);
> -
> - return 0;
> }
>
> static const struct of_device_id zynqmp_firmware_of_match[] = {
> @@ -1962,6 +1960,6 @@ static struct platform_driver zynqmp_firmware_driver = {
> .dev_groups = zynqmp_firmware_groups,
> },
> .probe = zynqmp_firmware_probe,
> - .remove = zynqmp_firmware_remove,
> + .remove_new = zynqmp_firmware_remove,
> };
> module_platform_driver(zynqmp_firmware_driver);
Reviewed-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 08/11] firmware: stratix10-rsu: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 08/11] firmware: stratix10-rsu: " Uwe Kleine-König
@ 2024-01-04 12:22 ` Dinh Nguyen
0 siblings, 0 replies; 20+ messages in thread
From: Dinh Nguyen @ 2024-01-04 12:22 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: kernel, linux-kernel
On 12/27/23 10:26, 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/firmware/stratix10-rsu.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
> index 4f7a7abada48..e20cee9c2d32 100644
> --- a/drivers/firmware/stratix10-rsu.c
> +++ b/drivers/firmware/stratix10-rsu.c
> @@ -793,17 +793,16 @@ static int stratix10_rsu_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int stratix10_rsu_remove(struct platform_device *pdev)
> +static void stratix10_rsu_remove(struct platform_device *pdev)
> {
> struct stratix10_rsu_priv *priv = platform_get_drvdata(pdev);
>
> stratix10_svc_free_channel(priv->chan);
> - return 0;
> }
>
> static struct platform_driver stratix10_rsu_driver = {
> .probe = stratix10_rsu_probe,
> - .remove = stratix10_rsu_remove,
> + .remove_new = stratix10_rsu_remove,
> .driver = {
> .name = "stratix10-rsu",
> .dev_groups = rsu_groups,
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 09/11] firmware: stratix10-svc: Convert to platform remove callback returning void
2023-12-27 16:26 ` [PATCH 09/11] firmware: stratix10-svc: " Uwe Kleine-König
@ 2024-01-04 12:22 ` Dinh Nguyen
0 siblings, 0 replies; 20+ messages in thread
From: Dinh Nguyen @ 2024-01-04 12:22 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: kernel, linux-kernel
On 12/27/23 10:26, 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/firmware/stratix10-svc.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
> index c693da60e9a9..528f37417aea 100644
> --- a/drivers/firmware/stratix10-svc.c
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -1251,7 +1251,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int stratix10_svc_drv_remove(struct platform_device *pdev)
> +static void stratix10_svc_drv_remove(struct platform_device *pdev)
> {
> struct stratix10_svc *svc = dev_get_drvdata(&pdev->dev);
> struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
> @@ -1267,13 +1267,11 @@ static int stratix10_svc_drv_remove(struct platform_device *pdev)
> if (ctrl->genpool)
> gen_pool_destroy(ctrl->genpool);
> list_del(&ctrl->node);
> -
> - return 0;
> }
>
> static struct platform_driver stratix10_svc_driver = {
> .probe = stratix10_svc_drv_probe,
> - .remove = stratix10_svc_drv_remove,
> + .remove_new = stratix10_svc_drv_remove,
> .driver = {
> .name = "stratix10-svc",
> .of_match_table = stratix10_svc_drv_match,
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-01-04 12:22 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 01/11] firmware: arm_scmi: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 02/11] firmware: arm_scpi: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 03/11] firmware: coreboot_table: " Uwe Kleine-König
2023-12-28 3:12 ` Tzung-Bi Shih
2023-12-27 16:26 ` [PATCH 04/11] firmware: imx-dsp: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 05/11] firmware: mtk-adsp-ipc: " Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
2023-12-27 17:07 ` Philippe Mathieu-Daudé
2023-12-27 20:46 ` Michael S. Tsirkin
2023-12-27 16:26 ` [PATCH 07/11] firmware: raspberrypi: " Uwe Kleine-König
2023-12-27 16:43 ` Florian Fainelli
2023-12-27 16:26 ` [PATCH 08/11] firmware: stratix10-rsu: " Uwe Kleine-König
2024-01-04 12:22 ` Dinh Nguyen
2023-12-27 16:26 ` [PATCH 09/11] firmware: stratix10-svc: " Uwe Kleine-König
2024-01-04 12:22 ` Dinh Nguyen
2023-12-27 16:26 ` [PATCH 10/11] firmware: turris-mox-rwtm: " Uwe Kleine-König
2023-12-28 15:32 ` Marek Behún
2023-12-27 16:26 ` [PATCH 11/11] firmware: zynqmp: " Uwe Kleine-König
2024-01-02 10:00 ` Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox