diff mbox series

[38/97] usb: gadget/r8a66597-udc: Convert to platform remove callback returning void

Message ID 20230517230239.187727-39-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit 9da2fa8fb8d445561b7d84cd7238c8a000ae5d84
Headers show
Series usb: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König May 17, 2023, 11:01 p.m. UTC
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() is
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/usb/gadget/udc/r8a66597-udc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Yoshihiro Shimoda May 18, 2023, 8:48 a.m. UTC | #1
Hi Uwe,

> From: Uwe Kleine-König, Sent: Thursday, May 18, 2023 8:02 AM
> 
> 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() is
> 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>

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Best regards,
Yoshihiro Shimoda

> ---
>  drivers/usb/gadget/udc/r8a66597-udc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
> index 38e4d6b505a0..51b665f15c8e 100644
> --- a/drivers/usb/gadget/udc/r8a66597-udc.c
> +++ b/drivers/usb/gadget/udc/r8a66597-udc.c
> @@ -1805,7 +1805,7 @@ static const struct usb_gadget_ops r8a66597_gadget_ops = {
>  	.set_selfpowered	= r8a66597_set_selfpowered,
>  };
> 
> -static int r8a66597_remove(struct platform_device *pdev)
> +static void r8a66597_remove(struct platform_device *pdev)
>  {
>  	struct r8a66597		*r8a66597 = platform_get_drvdata(pdev);
> 
> @@ -1816,8 +1816,6 @@ static int r8a66597_remove(struct platform_device *pdev)
>  	if (r8a66597->pdata->on_chip) {
>  		clk_disable_unprepare(r8a66597->clk);
>  	}
> -
> -	return 0;
>  }
> 
>  static void nop_completion(struct usb_ep *ep, struct usb_request *r)
> @@ -1966,7 +1964,7 @@ static int r8a66597_probe(struct platform_device *pdev)
> 
>  /*-------------------------------------------------------------------------*/
>  static struct platform_driver r8a66597_driver = {
> -	.remove =	r8a66597_remove,
> +	.remove_new =	r8a66597_remove,
>  	.driver		= {
>  		.name =	udc_name,
>  	},
> --
> 2.39.2
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 38e4d6b505a0..51b665f15c8e 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1805,7 +1805,7 @@  static const struct usb_gadget_ops r8a66597_gadget_ops = {
 	.set_selfpowered	= r8a66597_set_selfpowered,
 };
 
-static int r8a66597_remove(struct platform_device *pdev)
+static void r8a66597_remove(struct platform_device *pdev)
 {
 	struct r8a66597		*r8a66597 = platform_get_drvdata(pdev);
 
@@ -1816,8 +1816,6 @@  static int r8a66597_remove(struct platform_device *pdev)
 	if (r8a66597->pdata->on_chip) {
 		clk_disable_unprepare(r8a66597->clk);
 	}
-
-	return 0;
 }
 
 static void nop_completion(struct usb_ep *ep, struct usb_request *r)
@@ -1966,7 +1964,7 @@  static int r8a66597_probe(struct platform_device *pdev)
 
 /*-------------------------------------------------------------------------*/
 static struct platform_driver r8a66597_driver = {
-	.remove =	r8a66597_remove,
+	.remove_new =	r8a66597_remove,
 	.driver		= {
 		.name =	udc_name,
 	},