* [PATCH 00/10] usb: musb: Convert to platform remove callback returning void
@ 2023-04-05 14:09 Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 01/10] usb: musb: da8xx: " Uwe Kleine-König
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:09 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, Paul Cercueil, Matthias Brugger,
Conor Dooley, Daire McNamara, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Cc: linux-usb, kernel, linux-mips, AngeloGioacchino Del Regno,
linux-arm-kernel, linux-mediatek, linux-riscv, linux-omap,
linux-sunxi
Hello,
this patch series adapts the platform drivers below drivers/usb/musb
to use the .remove_new() callback. Compared to the traditional .remove()
callback .remove_new() returns no value. This is a good thing because
the driver core doesn't (and cannot) cope for errors during remove. The
only effect of a non-zero return value in .remove() is that the driver
core emits a warning. The device is removed anyhow and an early return
from .remove() usually yields a resource leak.
By changing the remove callback to return void driver authors cannot
reasonably assume any more that there is some kind of cleanup later.
All drivers touched here returned zero unconditionally in their remove
callback, so they could all be converted trivially to .remove_new().
Best regards
Uwe
Uwe Kleine-König (10):
usb: musb: da8xx: Convert to platform remove callback returning void
usb: musb: jz4740: Convert to platform remove callback returning void
usb: musb: mediatek: Convert to platform remove callback returning void
usb: musb: mpfs: Convert to platform remove callback returning void
usb: musb: musb_core: Convert to platform remove callback returning void
usb: musb: musb_dsps: Convert to platform remove callback returning void
usb: musb: omap2430: Convert to platform remove callback returning void
usb: musb: sunxi: Convert to platform remove callback returning void
usb: musb: tusb6010: Convert to platform remove callback returning void
usb: musb: ux500: Convert to platform remove callback returning void
drivers/usb/musb/da8xx.c | 6 ++----
drivers/usb/musb/jz4740.c | 6 ++----
drivers/usb/musb/mediatek.c | 6 ++----
drivers/usb/musb/mpfs.c | 6 ++----
drivers/usb/musb/musb_core.c | 5 ++---
drivers/usb/musb/musb_dsps.c | 6 ++----
drivers/usb/musb/omap2430.c | 6 ++----
drivers/usb/musb/sunxi.c | 6 ++----
drivers/usb/musb/tusb6010.c | 6 ++----
drivers/usb/musb/ux500.c | 6 ++----
10 files changed, 20 insertions(+), 39 deletions(-)
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
--
2.39.2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/10] usb: musb: da8xx: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 02/10] usb: musb: jz4740: " Uwe Kleine-König
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/da8xx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d47e5c94587b..912e32b78ac6 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -576,14 +576,12 @@ static int da8xx_probe(struct platform_device *pdev)
return ret;
}
-static int da8xx_remove(struct platform_device *pdev)
+static void da8xx_remove(struct platform_device *pdev)
{
struct da8xx_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
-
- return 0;
}
#ifdef CONFIG_PM_SLEEP
@@ -626,7 +624,7 @@ MODULE_DEVICE_TABLE(of, da8xx_id_table);
static struct platform_driver da8xx_driver = {
.probe = da8xx_probe,
- .remove = da8xx_remove,
+ .remove_new = da8xx_remove,
.driver = {
.name = "musb-da8xx",
.pm = &da8xx_pm_ops,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/10] usb: musb: jz4740: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 01/10] usb: musb: da8xx: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:12 ` Paul Cercueil
2023-04-06 12:12 ` Philippe Mathieu-Daudé
2023-04-05 14:10 ` [PATCH 03/10] usb: musb: mediatek: " Uwe Kleine-König
` (7 subsequent siblings)
9 siblings, 2 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Paul Cercueil, Bin Liu, Greg Kroah-Hartman; +Cc: linux-mips, linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/jz4740.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
index c7b1d2a394d9..5aabdd7e2511 100644
--- a/drivers/usb/musb/jz4740.c
+++ b/drivers/usb/musb/jz4740.c
@@ -308,14 +308,12 @@ static int jz4740_probe(struct platform_device *pdev)
return ret;
}
-static int jz4740_remove(struct platform_device *pdev)
+static void jz4740_remove(struct platform_device *pdev)
{
struct jz4740_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->pdev);
clk_disable_unprepare(glue->clk);
-
- return 0;
}
static const struct of_device_id jz4740_musb_of_match[] = {
@@ -327,7 +325,7 @@ MODULE_DEVICE_TABLE(of, jz4740_musb_of_match);
static struct platform_driver jz4740_driver = {
.probe = jz4740_probe,
- .remove = jz4740_remove,
+ .remove_new = jz4740_remove,
.driver = {
.name = "musb-jz4740",
.of_match_table = jz4740_musb_of_match,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/10] usb: musb: mediatek: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 01/10] usb: musb: da8xx: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 02/10] usb: musb: jz4740: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 04/10] usb: musb: mpfs: " Uwe Kleine-König
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, Matthias Brugger
Cc: AngeloGioacchino Del Regno, linux-usb, 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 (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/mediatek.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/mediatek.c b/drivers/usb/musb/mediatek.c
index 27b9bd258340..598ee5c0bf34 100644
--- a/drivers/usb/musb/mediatek.c
+++ b/drivers/usb/musb/mediatek.c
@@ -508,15 +508,13 @@ static int mtk_musb_probe(struct platform_device *pdev)
return ret;
}
-static int mtk_musb_remove(struct platform_device *pdev)
+static void mtk_musb_remove(struct platform_device *pdev)
{
struct mtk_glue *glue = platform_get_drvdata(pdev);
struct platform_device *usb_phy = glue->usb_phy;
platform_device_unregister(glue->musb_pdev);
usb_phy_generic_unregister(usb_phy);
-
- return 0;
}
#ifdef CONFIG_OF
@@ -529,7 +527,7 @@ MODULE_DEVICE_TABLE(of, mtk_musb_match);
static struct platform_driver mtk_musb_driver = {
.probe = mtk_musb_probe,
- .remove = mtk_musb_remove,
+ .remove_new = mtk_musb_remove,
.driver = {
.name = "musb-mtk",
.of_match_table = of_match_ptr(mtk_musb_match),
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/10] usb: musb: mpfs: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (2 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 03/10] usb: musb: mediatek: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:33 ` Conor Dooley
2023-04-05 14:10 ` [PATCH 05/10] usb: musb: musb_core: " Uwe Kleine-König
` (5 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Conor Dooley, Daire McNamara, Bin Liu, Greg Kroah-Hartman
Cc: linux-riscv, linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/mpfs.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c
index cea2e8108867..24b98716f7fc 100644
--- a/drivers/usb/musb/mpfs.c
+++ b/drivers/usb/musb/mpfs.c
@@ -235,15 +235,13 @@ static int mpfs_probe(struct platform_device *pdev)
return ret;
}
-static int mpfs_remove(struct platform_device *pdev)
+static void mpfs_remove(struct platform_device *pdev)
{
struct mpfs_glue *glue = platform_get_drvdata(pdev);
clk_disable_unprepare(glue->clk);
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(pdev);
-
- return 0;
}
#ifdef CONFIG_OF
@@ -256,7 +254,7 @@ MODULE_DEVICE_TABLE(of, mpfs_id_table);
static struct platform_driver mpfs_musb_driver = {
.probe = mpfs_probe,
- .remove = mpfs_remove,
+ .remove_new = mpfs_remove,
.driver = {
.name = "mpfs-musb",
.of_match_table = of_match_ptr(mpfs_id_table)
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/10] usb: musb: musb_core: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (3 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 04/10] usb: musb: mpfs: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 06/10] usb: musb: musb_dsps: " Uwe Kleine-König
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/musb_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 648bb6021c5e..d162afbbe19f 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2621,7 +2621,7 @@ static int musb_probe(struct platform_device *pdev)
return musb_init_controller(dev, irq, base);
}
-static int musb_remove(struct platform_device *pdev)
+static void musb_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct musb *musb = dev_to_musb(dev);
@@ -2657,7 +2657,6 @@ static int musb_remove(struct platform_device *pdev)
usb_phy_shutdown(musb->xceiv);
musb_free(musb);
device_init_wakeup(dev, 0);
- return 0;
}
#ifdef CONFIG_PM
@@ -2955,7 +2954,7 @@ static struct platform_driver musb_driver = {
.dev_groups = musb_groups,
},
.probe = musb_probe,
- .remove = musb_remove,
+ .remove_new = musb_remove,
};
module_platform_driver(musb_driver);
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/10] usb: musb: musb_dsps: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (4 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 05/10] usb: musb: musb_core: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 07/10] usb: musb: omap2430: " Uwe Kleine-König
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/musb_dsps.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index f75cde0f2b43..9119b1d51370 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -915,7 +915,7 @@ static int dsps_probe(struct platform_device *pdev)
return ret;
}
-static int dsps_remove(struct platform_device *pdev)
+static void dsps_remove(struct platform_device *pdev)
{
struct dsps_glue *glue = platform_get_drvdata(pdev);
@@ -923,8 +923,6 @@ static int dsps_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
iounmap(glue->usbss_base);
-
- return 0;
}
static const struct dsps_musb_wrapper am33xx_driver_data = {
@@ -1036,7 +1034,7 @@ static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);
static struct platform_driver dsps_usbss_driver = {
.probe = dsps_probe,
- .remove = dsps_remove,
+ .remove_new = dsps_remove,
.driver = {
.name = "musb-dsps",
.pm = &dsps_pm_ops,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/10] usb: musb: omap2430: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (5 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 06/10] usb: musb: musb_dsps: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 08/10] usb: musb: sunxi: " Uwe Kleine-König
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, linux-omap, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/omap2430.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 44a21ec865fb..b9ab0c48e2ee 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -471,14 +471,12 @@ static int omap2430_probe(struct platform_device *pdev)
return ret;
}
-static int omap2430_remove(struct platform_device *pdev)
+static void omap2430_remove(struct platform_device *pdev)
{
struct omap2430_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
pm_runtime_disable(glue->dev);
-
- return 0;
}
#ifdef CONFIG_PM
@@ -610,7 +608,7 @@ MODULE_DEVICE_TABLE(of, omap2430_id_table);
static struct platform_driver omap2430_driver = {
.probe = omap2430_probe,
- .remove = omap2430_remove,
+ .remove_new = omap2430_remove,
.driver = {
.name = "musb-omap2430",
.pm = DEV_PM_OPS,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/10] usb: musb: sunxi: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (6 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 07/10] usb: musb: omap2430: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 15:42 ` Jernej Škrabec
2023-04-05 14:10 ` [PATCH 09/10] usb: musb: tusb6010: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 10/10] usb: musb: ux500: " Uwe Kleine-König
9 siblings, 1 reply; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Cc: linux-usb, 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 (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/sunxi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index 9b622cd9b2bd..c5c6c4e09300 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -805,15 +805,13 @@ static int sunxi_musb_probe(struct platform_device *pdev)
return ret;
}
-static int sunxi_musb_remove(struct platform_device *pdev)
+static void sunxi_musb_remove(struct platform_device *pdev)
{
struct sunxi_glue *glue = platform_get_drvdata(pdev);
struct platform_device *usb_phy = glue->usb_phy;
platform_device_unregister(glue->musb_pdev);
usb_phy_generic_unregister(usb_phy);
-
- return 0;
}
static const struct sunxi_musb_cfg sun4i_a10_musb_cfg = {
@@ -862,7 +860,7 @@ MODULE_DEVICE_TABLE(of, sunxi_musb_match);
static struct platform_driver sunxi_musb_driver = {
.probe = sunxi_musb_probe,
- .remove = sunxi_musb_remove,
+ .remove_new = sunxi_musb_remove,
.driver = {
.name = "musb-sunxi",
.of_match_table = sunxi_musb_match,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/10] usb: musb: tusb6010: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (7 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 08/10] usb: musb: sunxi: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 10/10] usb: musb: ux500: " Uwe Kleine-König
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/tusb6010.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 5609b4e84d40..a1f29dbc62e6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1258,19 +1258,17 @@ static int tusb_probe(struct platform_device *pdev)
return 0;
}
-static int tusb_remove(struct platform_device *pdev)
+static void tusb_remove(struct platform_device *pdev)
{
struct tusb6010_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->phy);
-
- return 0;
}
static struct platform_driver tusb_driver = {
.probe = tusb_probe,
- .remove = tusb_remove,
+ .remove_new = tusb_remove,
.driver = {
.name = "musb-tusb",
},
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/10] usb: musb: ux500: Convert to platform remove callback returning void
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
` (8 preceding siblings ...)
2023-04-05 14:10 ` [PATCH 09/10] usb: musb: tusb6010: " Uwe Kleine-König
@ 2023-04-05 14:10 ` Uwe Kleine-König
9 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2023-04-05 14:10 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/usb/musb/ux500.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 8ea62c344328..c8d9d2a1d2f0 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -303,14 +303,12 @@ static int ux500_probe(struct platform_device *pdev)
return ret;
}
-static int ux500_remove(struct platform_device *pdev)
+static void ux500_remove(struct platform_device *pdev)
{
struct ux500_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
clk_disable_unprepare(glue->clk);
-
- return 0;
}
#ifdef CONFIG_PM_SLEEP
@@ -357,7 +355,7 @@ MODULE_DEVICE_TABLE(of, ux500_match);
static struct platform_driver ux500_driver = {
.probe = ux500_probe,
- .remove = ux500_remove,
+ .remove_new = ux500_remove,
.driver = {
.name = "musb-ux500",
.pm = &ux500_pm_ops,
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 02/10] usb: musb: jz4740: Convert to platform remove callback returning void
2023-04-05 14:10 ` [PATCH 02/10] usb: musb: jz4740: " Uwe Kleine-König
@ 2023-04-05 14:12 ` Paul Cercueil
2023-04-06 12:12 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 15+ messages in thread
From: Paul Cercueil @ 2023-04-05 14:12 UTC (permalink / raw)
To: Uwe Kleine-König, Bin Liu, Greg Kroah-Hartman
Cc: linux-mips, linux-usb, kernel
Le mercredi 05 avril 2023 à 16:10 +0200, Uwe Kleine-König a écrit :
> The .remove() callback for a platform driver returns an int which
> makes
> many driver authors wrongly assume it's possible to do error handling
> by
> returning an error code. However the value returned is (mostly)
> ignored
> and this typically results in resource leaks. To improve here there
> is a
> quest to make the remove callback return void. In the first step of
> this
> quest all drivers are converted to .remove_new() which already
> returns
> void.
>
> Trivially convert this driver from always returning zero in the
> remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Cheers,
-Paul
> ---
> drivers/usb/musb/jz4740.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
> index c7b1d2a394d9..5aabdd7e2511 100644
> --- a/drivers/usb/musb/jz4740.c
> +++ b/drivers/usb/musb/jz4740.c
> @@ -308,14 +308,12 @@ static int jz4740_probe(struct platform_device
> *pdev)
> return ret;
> }
>
> -static int jz4740_remove(struct platform_device *pdev)
> +static void jz4740_remove(struct platform_device *pdev)
> {
> struct jz4740_glue *glue = platform_get_drvdata(pdev);
>
> platform_device_unregister(glue->pdev);
> clk_disable_unprepare(glue->clk);
> -
> - return 0;
> }
>
> static const struct of_device_id jz4740_musb_of_match[] = {
> @@ -327,7 +325,7 @@ MODULE_DEVICE_TABLE(of, jz4740_musb_of_match);
>
> static struct platform_driver jz4740_driver = {
> .probe = jz4740_probe,
> - .remove = jz4740_remove,
> + .remove_new = jz4740_remove,
> .driver = {
> .name = "musb-jz4740",
> .of_match_table = jz4740_musb_of_match,
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 04/10] usb: musb: mpfs: Convert to platform remove callback returning void
2023-04-05 14:10 ` [PATCH 04/10] usb: musb: mpfs: " Uwe Kleine-König
@ 2023-04-05 14:33 ` Conor Dooley
0 siblings, 0 replies; 15+ messages in thread
From: Conor Dooley @ 2023-04-05 14:33 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Conor Dooley, Daire McNamara, Bin Liu, Greg Kroah-Hartman,
linux-riscv, linux-usb, kernel
[-- Attachment #1: Type: text/plain, Size: 2044 bytes --]
On Wed, Apr 05, 2023 at 04:10:03PM +0200, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Thanks,
Conor.
> ---
> drivers/usb/musb/mpfs.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c
> index cea2e8108867..24b98716f7fc 100644
> --- a/drivers/usb/musb/mpfs.c
> +++ b/drivers/usb/musb/mpfs.c
> @@ -235,15 +235,13 @@ static int mpfs_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int mpfs_remove(struct platform_device *pdev)
> +static void mpfs_remove(struct platform_device *pdev)
> {
> struct mpfs_glue *glue = platform_get_drvdata(pdev);
>
> clk_disable_unprepare(glue->clk);
> platform_device_unregister(glue->musb);
> usb_phy_generic_unregister(pdev);
> -
> - return 0;
> }
>
> #ifdef CONFIG_OF
> @@ -256,7 +254,7 @@ MODULE_DEVICE_TABLE(of, mpfs_id_table);
>
> static struct platform_driver mpfs_musb_driver = {
> .probe = mpfs_probe,
> - .remove = mpfs_remove,
> + .remove_new = mpfs_remove,
> .driver = {
> .name = "mpfs-musb",
> .of_match_table = of_match_ptr(mpfs_id_table)
> --
> 2.39.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 08/10] usb: musb: sunxi: Convert to platform remove callback returning void
2023-04-05 14:10 ` [PATCH 08/10] usb: musb: sunxi: " Uwe Kleine-König
@ 2023-04-05 15:42 ` Jernej Škrabec
0 siblings, 0 replies; 15+ messages in thread
From: Jernej Škrabec @ 2023-04-05 15:42 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, Chen-Yu Tsai, Samuel Holland,
Uwe Kleine-König
Cc: linux-usb, linux-arm-kernel, linux-sunxi, kernel
Dne sreda, 05. april 2023 ob 16:10:07 CEST je Uwe Kleine-König napisal(a):
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 02/10] usb: musb: jz4740: Convert to platform remove callback returning void
2023-04-05 14:10 ` [PATCH 02/10] usb: musb: jz4740: " Uwe Kleine-König
2023-04-05 14:12 ` Paul Cercueil
@ 2023-04-06 12:12 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-04-06 12:12 UTC (permalink / raw)
To: Uwe Kleine-König, Paul Cercueil, Bin Liu, Greg Kroah-Hartman
Cc: linux-mips, linux-usb, kernel
On 5/4/23 16:10, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/usb/musb/jz4740.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2023-04-06 12:13 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05 14:09 [PATCH 00/10] usb: musb: Convert to platform remove callback returning void Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 01/10] usb: musb: da8xx: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 02/10] usb: musb: jz4740: " Uwe Kleine-König
2023-04-05 14:12 ` Paul Cercueil
2023-04-06 12:12 ` Philippe Mathieu-Daudé
2023-04-05 14:10 ` [PATCH 03/10] usb: musb: mediatek: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 04/10] usb: musb: mpfs: " Uwe Kleine-König
2023-04-05 14:33 ` Conor Dooley
2023-04-05 14:10 ` [PATCH 05/10] usb: musb: musb_core: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 06/10] usb: musb: musb_dsps: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 07/10] usb: musb: omap2430: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 08/10] usb: musb: sunxi: " Uwe Kleine-König
2023-04-05 15:42 ` Jernej Škrabec
2023-04-05 14:10 ` [PATCH 09/10] usb: musb: tusb6010: " Uwe Kleine-König
2023-04-05 14:10 ` [PATCH 10/10] usb: musb: ux500: " Uwe Kleine-König
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).