Re: [PATCH] sh: push-switch: Convert to platform remove callback returning void

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.linux.ports.sh.devel
Message-ID <9e26c50be78ff415f484cb9af9546a49002d3851.camel@physik.fu-berlin.de>
On Wed, 2024-03-06 at 22:19 +0100, 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() will be 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 <[email protected]>
> ---
>  arch/sh/drivers/push-switch.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
> index 6ecba5f521eb..362e4860bf52 100644
> --- a/arch/sh/drivers/push-switch.c
> +++ b/arch/sh/drivers/push-switch.c
> @@ -91,7 +91,7 @@ static int switch_drv_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int switch_drv_remove(struct platform_device *pdev)
> +static void switch_drv_remove(struct platform_device *pdev)
>  {
>  	struct push_switch *psw = platform_get_drvdata(pdev);
>  	struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
> @@ -106,13 +106,11 @@ static int switch_drv_remove(struct platform_device *pdev)
>  	free_irq(irq, pdev);
>  
>  	kfree(psw);
> -
> -	return 0;
>  }
>  
>  static struct platform_driver switch_driver = {
>  	.probe		= switch_drv_probe,
> -	.remove		= switch_drv_remove,
> +	.remove_new	= switch_drv_remove,
>  	.driver		= {
>  		.name	= DRV_NAME,
>  	},
> 
> base-commit: 11afac187274a6177a7ac82997f8691c0f469e41

Thanks for elaborate explanation in the commit message which makes it much
easier to understand the changes and the reasoning behind it. I fully agree
with the changes.

Reviewed-by: John Paul Adrian Glaubitz <[email protected]>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.