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

Claudiu.Beznea at microchip.com Claudiu.Beznea at microchip.com
Wed May 17 22:57:17 PDT 2023


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 at pengutronix.de>
Reviewed-by: Claudiu Beznea <claudiu.beznea at 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
> 



More information about the linux-arm-kernel mailing list