Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [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 04/10] usb: musb: mpfs: " Uwe Kleine-König
  0 siblings, 1 reply; 3+ 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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ 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
@ 2023-04-05 14:10 ` Uwe Kleine-König
  2023-04-05 14:33   ` Conor Dooley
  0 siblings, 1 reply; 3+ 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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ 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; 3+ 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.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 #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2023-04-05 14:33 UTC | newest]

Thread overview: 3+ 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 04/10] usb: musb: mpfs: " Uwe Kleine-König
2023-04-05 14:33   ` Conor Dooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox