diff mbox series

[051/117] media: rcar_drif: Convert to platform remove callback returning void

Message ID 20230326143224.572654-54-u.kleine-koenig@pengutronix.de (mailing list archive)
State Mainlined
Commit 2ff72c6c42b98323545c0c3e79b0edd3cef93f66
Delegated to: Kieran Bingham
Headers show
Series media: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König March 26, 2023, 2:31 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 (mostly) ignored
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.

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/media/platform/renesas/rcar_drif.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Geert Uytterhoeven March 27, 2023, 7:12 a.m. UTC | #1
On Sun, Mar 26, 2023 at 4:33 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> 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 (mostly) ignored
> 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.
>
> 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: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
Fabrizio Castro March 28, 2023, 1:54 p.m. UTC | #2
> 
> 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 (mostly)
> ignored
> 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.
> 
> 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: Fabrizio Castro <fabrizio.castro.jz@renesas.com>


> ---
>  drivers/media/platform/renesas/rcar_drif.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar_drif.c
> b/drivers/media/platform/renesas/rcar_drif.c
> index 3fec41f6e964..3a92f4535c18 100644
> --- a/drivers/media/platform/renesas/rcar_drif.c
> +++ b/drivers/media/platform/renesas/rcar_drif.c
> @@ -1433,19 +1433,17 @@ static int rcar_drif_probe(struct
> platform_device *pdev)
>  }
> 
>  /* DRIF channel remove */
> -static int rcar_drif_remove(struct platform_device *pdev)
> +static void rcar_drif_remove(struct platform_device *pdev)
>  {
>  	struct rcar_drif *ch = platform_get_drvdata(pdev);
>  	struct rcar_drif_sdr *sdr = ch->sdr;
> 
>  	/* Channel 0 will be the SDR instance */
>  	if (ch->num)
> -		return 0;
> +		return;
> 
>  	/* SDR instance */
>  	rcar_drif_sdr_remove(sdr);
> -
> -	return 0;
>  }
> 
>  /* FIXME: Implement suspend/resume support */
> @@ -1476,7 +1474,7 @@ static struct platform_driver rcar_drif_driver =
> {
>  		.pm = &rcar_drif_pm_ops,
>  		},
>  	.probe = rcar_drif_probe,
> -	.remove = rcar_drif_remove,
> +	.remove_new = rcar_drif_remove,
>  };
> 
>  module_platform_driver(rcar_drif_driver);
> --
> 2.39.2
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
index 3fec41f6e964..3a92f4535c18 100644
--- a/drivers/media/platform/renesas/rcar_drif.c
+++ b/drivers/media/platform/renesas/rcar_drif.c
@@ -1433,19 +1433,17 @@  static int rcar_drif_probe(struct platform_device *pdev)
 }
 
 /* DRIF channel remove */
-static int rcar_drif_remove(struct platform_device *pdev)
+static void rcar_drif_remove(struct platform_device *pdev)
 {
 	struct rcar_drif *ch = platform_get_drvdata(pdev);
 	struct rcar_drif_sdr *sdr = ch->sdr;
 
 	/* Channel 0 will be the SDR instance */
 	if (ch->num)
-		return 0;
+		return;
 
 	/* SDR instance */
 	rcar_drif_sdr_remove(sdr);
-
-	return 0;
 }
 
 /* FIXME: Implement suspend/resume support */
@@ -1476,7 +1474,7 @@  static struct platform_driver rcar_drif_driver = {
 		.pm = &rcar_drif_pm_ops,
 		},
 	.probe = rcar_drif_probe,
-	.remove = rcar_drif_remove,
+	.remove_new = rcar_drif_remove,
 };
 
 module_platform_driver(rcar_drif_driver);