All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Rich Felker" <dalias@libc.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Duoming Zhou <duoming@zju.edu.cn>,
	linux-sh@vger.kernel.org, kernel@vpengutronix.de
Subject: Re: [PATCH] sh: push-switch: Convert to platform remove callback returning void
Date: Mon, 29 Apr 2024 10:30:08 +0200	[thread overview]
Message-ID: <9e26c50be78ff415f484cb9af9546a49002d3851.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <20240306211947.97103-2-u.kleine-koenig@pengutronix.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 <u.kleine-koenig@pengutronix.de>
> ---
>  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 <glaubitz@physik.fu-berlin.de>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

  parent reply	other threads:[~2024-04-29  8:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 21:19 [PATCH] sh: push-switch: Convert to platform remove callback returning void Uwe Kleine-König
2024-03-07  8:41 ` Geert Uytterhoeven
2024-04-11  7:18 ` Uwe Kleine-König
2024-04-11  7:47   ` John Paul Adrian Glaubitz
2024-04-11  7:49     ` John Paul Adrian Glaubitz
2024-04-29  7:22       ` Uwe Kleine-König
2024-04-29  7:24         ` John Paul Adrian Glaubitz
2024-04-29  8:30 ` John Paul Adrian Glaubitz [this message]
2024-05-02 10:27 ` John Paul Adrian Glaubitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e26c50be78ff415f484cb9af9546a49002d3851.camel@physik.fu-berlin.de \
    --to=glaubitz@physik.fu-berlin.de \
    --cc=dalias@libc.org \
    --cc=duoming@zju.edu.cn \
    --cc=geert+renesas@glider.be \
    --cc=kernel@vpengutronix.de \
    --cc=linux-sh@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.