linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] usb: phy: Convert to platform remove callback returning void
@ 2023-03-19  9:24 Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 01/11] usb: phy: ab8500: " Uwe Kleine-König
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ran Wang, Yang Yingliang, Li Jun,
	Sean Anderson, Sascha Hauer, Linus Walleij, Colin Ian King,
	Shawn Guo, Frank Li, Thierry Reding, Jonathan Hunter,
	Dmitry Torokhov
  Cc: linux-usb, kernel, linuxppc-dev, Fabio Estevam, NXP Linux Team,
	linux-arm-kernel, linux-tegra

Hello,

this series adapts the platform drivers below drivers/usb/phy 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 could be converted trivally as they all returned zero
unconditionally in their .remove() callback.

Best regards
Uwe


Uwe Kleine-König (11):
  usb: phy: ab8500: Convert to platform remove callback returning void
  usb: phy: am335x: Convert to platform remove callback returning void
  usb: phy: fsl: Convert to platform remove callback returning void
  usb: phy: generic: Convert to platform remove callback returning void
  usb: phy: gpio-vbus: Convert to platform remove callback returning
    void
  usb: phy: keystone: Convert to platform remove callback returning void
  usb: phy: mv: Convert to platform remove callback returning void
  usb: phy: mxs: Convert to platform remove callback returning void
  usb: phy: tahvo: Convert to platform remove callback returning void
  usb: phy: tegra: Convert to platform remove callback returning void
  usb: phy: twl6030: Convert to platform remove callback returning void

 drivers/usb/phy/phy-ab8500-usb.c    | 6 ++----
 drivers/usb/phy/phy-am335x.c        | 5 ++---
 drivers/usb/phy/phy-fsl-usb.c       | 6 ++----
 drivers/usb/phy/phy-generic.c       | 6 ++----
 drivers/usb/phy/phy-gpio-vbus-usb.c | 6 ++----
 drivers/usb/phy/phy-keystone.c      | 6 ++----
 drivers/usb/phy/phy-mv-usb.c        | 6 ++----
 drivers/usb/phy/phy-mxs-usb.c       | 6 ++----
 drivers/usb/phy/phy-tahvo.c         | 6 ++----
 drivers/usb/phy/phy-tegra-usb.c     | 6 ++----
 drivers/usb/phy/phy-twl6030-usb.c   | 6 ++----
 11 files changed, 22 insertions(+), 43 deletions(-)


base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
-- 
2.39.2


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

* [PATCH 01/11] usb: phy: ab8500: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 02/11] usb: phy: am335x: " Uwe Kleine-König
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: 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/phy/phy-ab8500-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 4c52ba96f17e..408f47e39025 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -965,7 +965,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int ab8500_usb_remove(struct platform_device *pdev)
+static void ab8500_usb_remove(struct platform_device *pdev)
 {
 	struct ab8500_usb *ab = platform_get_drvdata(pdev);
 
@@ -977,8 +977,6 @@ static int ab8500_usb_remove(struct platform_device *pdev)
 		ab8500_usb_host_phy_dis(ab);
 	else if (ab->mode == USB_PERIPHERAL)
 		ab8500_usb_peri_phy_dis(ab);
-
-	return 0;
 }
 
 static const struct platform_device_id ab8500_usb_devtype[] = {
@@ -989,7 +987,7 @@ MODULE_DEVICE_TABLE(platform, ab8500_usb_devtype);
 
 static struct platform_driver ab8500_usb_driver = {
 	.probe		= ab8500_usb_probe,
-	.remove		= ab8500_usb_remove,
+	.remove_new	= ab8500_usb_remove,
 	.id_table	= ab8500_usb_devtype,
 	.driver		= {
 		.name	= "abx5x0-usb",
-- 
2.39.2


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

* [PATCH 02/11] usb: phy: am335x: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 01/11] usb: phy: ab8500: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 03/11] usb: phy: fsl: " Uwe Kleine-König
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: 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/phy/phy-am335x.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 8524475d942d..e39665cf4b4a 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -82,12 +82,11 @@ static int am335x_phy_probe(struct platform_device *pdev)
 	return usb_add_phy_dev(&am_phy->usb_phy_gen.phy);
 }
 
-static int am335x_phy_remove(struct platform_device *pdev)
+static void am335x_phy_remove(struct platform_device *pdev)
 {
 	struct am335x_phy *am_phy = platform_get_drvdata(pdev);
 
 	usb_remove_phy(&am_phy->usb_phy_gen.phy);
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -134,7 +133,7 @@ MODULE_DEVICE_TABLE(of, am335x_phy_ids);
 
 static struct platform_driver am335x_phy_driver = {
 	.probe          = am335x_phy_probe,
-	.remove         = am335x_phy_remove,
+	.remove_new     = am335x_phy_remove,
 	.driver         = {
 		.name   = "am335x-phy-driver",
 		.pm = &am335x_pm_ops,
-- 
2.39.2


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

* [PATCH 03/11] usb: phy: fsl: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 01/11] usb: phy: ab8500: " Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 02/11] usb: phy: am335x: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 04/11] usb: phy: generic: " Uwe Kleine-König
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Ran Wang, Greg Kroah-Hartman; +Cc: linux-usb, linuxppc-dev, 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/phy/phy-fsl-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 972704262b02..79617bb0a70e 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -983,7 +983,7 @@ static int fsl_otg_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int fsl_otg_remove(struct platform_device *pdev)
+static void fsl_otg_remove(struct platform_device *pdev)
 {
 	struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev);
 
@@ -998,13 +998,11 @@ static int fsl_otg_remove(struct platform_device *pdev)
 
 	if (pdata->exit)
 		pdata->exit(pdev);
-
-	return 0;
 }
 
 struct platform_driver fsl_otg_driver = {
 	.probe = fsl_otg_probe,
-	.remove = fsl_otg_remove,
+	.remove_new = fsl_otg_remove,
 	.driver = {
 		.name = driver_name,
 		.owner = THIS_MODULE,
-- 
2.39.2


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

* [PATCH 04/11] usb: phy: generic: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 03/11] usb: phy: fsl: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 05/11] usb: phy: gpio-vbus: " Uwe Kleine-König
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Yang Yingliang, Li Jun, Sean Anderson, Sascha Hauer
  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/phy/phy-generic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index c1309ea24a52..770081b828a4 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -330,13 +330,11 @@ static int usb_phy_generic_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int usb_phy_generic_remove(struct platform_device *pdev)
+static void usb_phy_generic_remove(struct platform_device *pdev)
 {
 	struct usb_phy_generic *nop = platform_get_drvdata(pdev);
 
 	usb_remove_phy(&nop->phy);
-
-	return 0;
 }
 
 static const struct of_device_id nop_xceiv_dt_ids[] = {
@@ -348,7 +346,7 @@ MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids);
 
 static struct platform_driver usb_phy_generic_driver = {
 	.probe		= usb_phy_generic_probe,
-	.remove		= usb_phy_generic_remove,
+	.remove_new	= usb_phy_generic_remove,
 	.driver		= {
 		.name	= "usb_phy_generic",
 		.of_match_table = nop_xceiv_dt_ids,
-- 
2.39.2


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

* [PATCH 05/11] usb: phy: gpio-vbus: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 04/11] usb: phy: generic: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19 20:43   ` Linus Walleij
  2023-03-19  9:24 ` [PATCH 06/11] usb: phy: keystone: " Uwe Kleine-König
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Linus Walleij; +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/phy/phy-gpio-vbus-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index 12dfeff7de3d..817c242a76ca 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -325,7 +325,7 @@ static int gpio_vbus_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int gpio_vbus_remove(struct platform_device *pdev)
+static void gpio_vbus_remove(struct platform_device *pdev)
 {
 	struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
 
@@ -333,8 +333,6 @@ static int gpio_vbus_remove(struct platform_device *pdev)
 	cancel_delayed_work_sync(&gpio_vbus->work);
 
 	usb_remove_phy(&gpio_vbus->phy);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -386,7 +384,7 @@ static struct platform_driver gpio_vbus_driver = {
 		.of_match_table = gpio_vbus_of_match,
 	},
 	.probe		= gpio_vbus_probe,
-	.remove		= gpio_vbus_remove,
+	.remove_new	= gpio_vbus_remove,
 };
 
 module_platform_driver(gpio_vbus_driver);
-- 
2.39.2


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

* [PATCH 06/11] usb: phy: keystone: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 05/11] usb: phy: gpio-vbus: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 07/11] usb: phy: mv: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Colin Ian King; +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/phy/phy-keystone.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-keystone.c b/drivers/usb/phy/phy-keystone.c
index f75912279b39..bd9a98ad1b30 100644
--- a/drivers/usb/phy/phy-keystone.c
+++ b/drivers/usb/phy/phy-keystone.c
@@ -88,13 +88,11 @@ static int keystone_usbphy_probe(struct platform_device *pdev)
 	return usb_add_phy_dev(&k_phy->usb_phy_gen.phy);
 }
 
-static int keystone_usbphy_remove(struct platform_device *pdev)
+static void keystone_usbphy_remove(struct platform_device *pdev)
 {
 	struct keystone_usbphy *k_phy = platform_get_drvdata(pdev);
 
 	usb_remove_phy(&k_phy->usb_phy_gen.phy);
-
-	return 0;
 }
 
 static const struct of_device_id keystone_usbphy_ids[] = {
@@ -105,7 +103,7 @@ MODULE_DEVICE_TABLE(of, keystone_usbphy_ids);
 
 static struct platform_driver keystone_usbphy_driver = {
 	.probe          = keystone_usbphy_probe,
-	.remove         = keystone_usbphy_remove,
+	.remove_new     = keystone_usbphy_remove,
 	.driver         = {
 		.name   = "keystone-usbphy",
 		.of_match_table = keystone_usbphy_ids,
-- 
2.39.2


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

* [PATCH 07/11] usb: phy: mv: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 06/11] usb: phy: keystone: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 08/11] usb: phy: mxs: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: 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/phy/phy-mv-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 86503b7d695c..df7c27474a75 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -644,7 +644,7 @@ static const struct attribute_group *mv_otg_groups[] = {
 	NULL,
 };
 
-static int mv_otg_remove(struct platform_device *pdev)
+static void mv_otg_remove(struct platform_device *pdev)
 {
 	struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
@@ -654,8 +654,6 @@ static int mv_otg_remove(struct platform_device *pdev)
 	mv_otg_disable(mvotg);
 
 	usb_remove_phy(&mvotg->phy);
-
-	return 0;
 }
 
 static int mv_otg_probe(struct platform_device *pdev)
@@ -869,7 +867,7 @@ static int mv_otg_resume(struct platform_device *pdev)
 
 static struct platform_driver mv_otg_driver = {
 	.probe = mv_otg_probe,
-	.remove = mv_otg_remove,
+	.remove_new = mv_otg_remove,
 	.driver = {
 		   .name = driver_name,
 		   .dev_groups = mv_otg_groups,
-- 
2.39.2


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

* [PATCH 08/11] usb: phy: mxs: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 07/11] usb: phy: mv: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-20 14:54   ` [EXT] " Frank Li
  2023-03-19  9:24 ` [PATCH 09/11] usb: phy: tahvo: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shawn Guo, Sascha Hauer, Frank Li
  Cc: Fabio Estevam, NXP Linux Team, linux-usb, 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 (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/phy/phy-mxs-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index d2836ef5d15c..b21eecacc3b7 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -801,13 +801,11 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	return usb_add_phy_dev(&mxs_phy->phy);
 }
 
-static int mxs_phy_remove(struct platform_device *pdev)
+static void mxs_phy_remove(struct platform_device *pdev)
 {
 	struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
 
 	usb_remove_phy(&mxs_phy->phy);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -853,7 +851,7 @@ static SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend,
 
 static struct platform_driver mxs_phy_driver = {
 	.probe = mxs_phy_probe,
-	.remove = mxs_phy_remove,
+	.remove_new = mxs_phy_remove,
 	.driver = {
 		.name = DRIVER_NAME,
 		.of_match_table = mxs_phy_dt_ids,
-- 
2.39.2


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

* [PATCH 09/11] usb: phy: tahvo: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 08/11] usb: phy: mxs: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 10/11] usb: phy: tegra: " Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 11/11] usb: phy: twl6030: " Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: 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/phy/phy-tahvo.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index f2d2cc586c5b..47562d49dfc1 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -412,7 +412,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int tahvo_usb_remove(struct platform_device *pdev)
+static void tahvo_usb_remove(struct platform_device *pdev)
 {
 	struct tahvo_usb *tu = platform_get_drvdata(pdev);
 
@@ -420,13 +420,11 @@ static int tahvo_usb_remove(struct platform_device *pdev)
 	usb_remove_phy(&tu->phy);
 	if (!IS_ERR(tu->ick))
 		clk_disable(tu->ick);
-
-	return 0;
 }
 
 static struct platform_driver tahvo_usb_driver = {
 	.probe		= tahvo_usb_probe,
-	.remove		= tahvo_usb_remove,
+	.remove_new	= tahvo_usb_remove,
 	.driver		= {
 		.name	= "tahvo-usb",
 		.dev_groups = tahvo_groups,
-- 
2.39.2


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

* [PATCH 10/11] usb: phy: tegra: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 09/11] usb: phy: tahvo: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  2023-03-19  9:24 ` [PATCH 11/11] usb: phy: twl6030: " Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter, Dmitry Torokhov
  Cc: linux-usb, linux-tegra, 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/phy/phy-tegra-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index f0240107edb1..014a96fdbd36 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -1486,18 +1486,16 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
 	return usb_add_phy_dev(&tegra_phy->u_phy);
 }
 
-static int tegra_usb_phy_remove(struct platform_device *pdev)
+static void tegra_usb_phy_remove(struct platform_device *pdev)
 {
 	struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev);
 
 	usb_remove_phy(&tegra_phy->u_phy);
-
-	return 0;
 }
 
 static struct platform_driver tegra_usb_phy_driver = {
 	.probe		= tegra_usb_phy_probe,
-	.remove		= tegra_usb_phy_remove,
+	.remove_new	= tegra_usb_phy_remove,
 	.driver		= {
 		.name	= "tegra-phy",
 		.of_match_table = tegra_usb_phy_id_table,
-- 
2.39.2


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

* [PATCH 11/11] usb: phy: twl6030: Convert to platform remove callback returning void
  2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2023-03-19  9:24 ` [PATCH 10/11] usb: phy: tegra: " Uwe Kleine-König
@ 2023-03-19  9:24 ` Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-03-19  9:24 UTC (permalink / raw)
  To: 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/phy/phy-twl6030-usb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
index ab3c38a7d8ac..c3ce6b1054f1 100644
--- a/drivers/usb/phy/phy-twl6030-usb.c
+++ b/drivers/usb/phy/phy-twl6030-usb.c
@@ -409,7 +409,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
 	return status;
 }
 
-static int twl6030_usb_remove(struct platform_device *pdev)
+static void twl6030_usb_remove(struct platform_device *pdev)
 {
 	struct twl6030_usb *twl = platform_get_drvdata(pdev);
 
@@ -422,8 +422,6 @@ static int twl6030_usb_remove(struct platform_device *pdev)
 	free_irq(twl->irq2, twl);
 	regulator_put(twl->usb3v3);
 	cancel_work_sync(&twl->set_vbus_work);
-
-	return 0;
 }
 
 static const struct of_device_id twl6030_usb_id_table[] = {
@@ -434,7 +432,7 @@ MODULE_DEVICE_TABLE(of, twl6030_usb_id_table);
 
 static struct platform_driver twl6030_usb_driver = {
 	.probe		= twl6030_usb_probe,
-	.remove		= twl6030_usb_remove,
+	.remove_new	= twl6030_usb_remove,
 	.driver		= {
 		.name	= "twl6030_usb",
 		.of_match_table = of_match_ptr(twl6030_usb_id_table),
-- 
2.39.2


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

* Re: [PATCH 05/11] usb: phy: gpio-vbus: Convert to platform remove callback returning void
  2023-03-19  9:24 ` [PATCH 05/11] usb: phy: gpio-vbus: " Uwe Kleine-König
@ 2023-03-19 20:43   ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2023-03-19 20:43 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Greg Kroah-Hartman, linux-usb, kernel

On Sun, Mar 19, 2023 at 10:24 AM 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 (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: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* RE: [EXT] [PATCH 08/11] usb: phy: mxs: Convert to platform remove callback returning void
  2023-03-19  9:24 ` [PATCH 08/11] usb: phy: mxs: " Uwe Kleine-König
@ 2023-03-20 14:54   ` Frank Li
  0 siblings, 0 replies; 14+ messages in thread
From: Frank Li @ 2023-03-20 14:54 UTC (permalink / raw)
  To: Uwe Kleine-König, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer
  Cc: Fabio Estevam, dl-linux-imx, linux-usb, linux-arm-kernel, kernel



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Sunday, March 19, 2023 4:24 AM
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Frank Li
> <frank.li@nxp.com>
> Cc: Fabio Estevam <festevam@gmail.com>; dl-linux-imx <linux-
> imx@nxp.com>; linux-usb@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; kernel@pengutronix.de
> Subject: [EXT] [PATCH 08/11] usb: phy: mxs: Convert to platform remove
> callback returning void
> 
> Caution: EXT Email
> 
> 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: Frank Li <Frank.li@nxp.com>
 

>  drivers/usb/phy/phy-mxs-usb.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-
> usb.c
> index d2836ef5d15c..b21eecacc3b7 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -801,13 +801,11 @@ static int mxs_phy_probe(struct platform_device
> *pdev)
>         return usb_add_phy_dev(&mxs_phy->phy);
>  }
> 
> -static int mxs_phy_remove(struct platform_device *pdev)
> +static void mxs_phy_remove(struct platform_device *pdev)
>  {
>         struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
> 
>         usb_remove_phy(&mxs_phy->phy);
> -
> -       return 0;
>  }
> 
>  #ifdef CONFIG_PM_SLEEP
> @@ -853,7 +851,7 @@ static SIMPLE_DEV_PM_OPS(mxs_phy_pm,
> mxs_phy_system_suspend,
> 
>  static struct platform_driver mxs_phy_driver = {
>         .probe = mxs_phy_probe,
> -       .remove = mxs_phy_remove,
> +       .remove_new = mxs_phy_remove,
>         .driver = {
>                 .name = DRIVER_NAME,
>                 .of_match_table = mxs_phy_dt_ids,
> --
> 2.39.2


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

end of thread, other threads:[~2023-03-20 14:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-19  9:24 [PATCH 00/11] usb: phy: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 01/11] usb: phy: ab8500: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 02/11] usb: phy: am335x: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 03/11] usb: phy: fsl: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 04/11] usb: phy: generic: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 05/11] usb: phy: gpio-vbus: " Uwe Kleine-König
2023-03-19 20:43   ` Linus Walleij
2023-03-19  9:24 ` [PATCH 06/11] usb: phy: keystone: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 07/11] usb: phy: mv: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 08/11] usb: phy: mxs: " Uwe Kleine-König
2023-03-20 14:54   ` [EXT] " Frank Li
2023-03-19  9:24 ` [PATCH 09/11] usb: phy: tahvo: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 10/11] usb: phy: tegra: " Uwe Kleine-König
2023-03-19  9:24 ` [PATCH 11/11] usb: phy: twl6030: " 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).