diff mbox series

[26/97] usb: gadget/atmel_usba_udc: Convert to platform remove callback returning void

Message ID 20230517230239.187727-27-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit e28137b056ced4e014a2e2206b8d59236c40d369
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/atmel_usba_udc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Claudiu Beznea May 18, 2023, 5:57 a.m. UTC | #1
On 18.05.2023 02:01, 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() 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>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 53ca38c4b3ec..6c0ed3fa5eb1 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -2369,7 +2369,7 @@ static int usba_udc_probe(struct platform_device *pdev)
>         return 0;
>  }
> 
> -static int usba_udc_remove(struct platform_device *pdev)
> +static void usba_udc_remove(struct platform_device *pdev)
>  {
>         struct usba_udc *udc;
>         int i;
> @@ -2382,8 +2382,6 @@ static int usba_udc_remove(struct platform_device *pdev)
>         for (i = 1; i < udc->num_ep; i++)
>                 usba_ep_cleanup_debugfs(&udc->usba_ep[i]);
>         usba_cleanup_debugfs(udc);
> -
> -       return 0;
>  }
> 
>  #ifdef CONFIG_PM_SLEEP
> @@ -2450,7 +2448,7 @@ static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
> 
>  static struct platform_driver udc_driver = {
>         .probe          = usba_udc_probe,
> -       .remove         = usba_udc_remove,
> +       .remove_new     = usba_udc_remove,
>         .driver         = {
>                 .name           = "atmel_usba_udc",
>                 .pm             = &usba_udc_pm_ops,
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 53ca38c4b3ec..6c0ed3fa5eb1 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2369,7 +2369,7 @@  static int usba_udc_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int usba_udc_remove(struct platform_device *pdev)
+static void usba_udc_remove(struct platform_device *pdev)
 {
 	struct usba_udc *udc;
 	int i;
@@ -2382,8 +2382,6 @@  static int usba_udc_remove(struct platform_device *pdev)
 	for (i = 1; i < udc->num_ep; i++)
 		usba_ep_cleanup_debugfs(&udc->usba_ep[i]);
 	usba_cleanup_debugfs(udc);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -2450,7 +2448,7 @@  static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
 
 static struct platform_driver udc_driver = {
 	.probe		= usba_udc_probe,
-	.remove		= usba_udc_remove,
+	.remove_new	= usba_udc_remove,
 	.driver		= {
 		.name		= "atmel_usba_udc",
 		.pm		= &usba_udc_pm_ops,