diff mbox series

[2/4] drm/mediatek: Convert to platform remove callback returning void

Message ID 4a64dfbfbcfdf9b7cd46bc8026223e69a4b453b4.1712681770.git.u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series gpu: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König April 9, 2024, 5:02 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() 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>
---
 drivers/gpu/drm/mediatek/mtk_padding.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

CK Hu (胡俊光) May 16, 2024, 2:54 a.m. UTC | #1
Hi, Uwe:

On Tue, 2024-04-09 at 19:02 +0200, 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.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpu/drm/mediatek/mtk_padding.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_padding.c b/drivers/gpu/drm/mediatek/mtk_padding.c
> index 0d6451c149b6..9f92b720aaae 100644
> --- a/drivers/gpu/drm/mediatek/mtk_padding.c
> +++ b/drivers/gpu/drm/mediatek/mtk_padding.c
> @@ -137,10 +137,9 @@ static int mtk_padding_probe(struct platform_device *pdev)
>  return 0;
>  }
>  
> -static int mtk_padding_remove(struct platform_device *pdev)
> +static void mtk_padding_remove(struct platform_device *pdev)
>  {
>  component_del(&pdev->dev, &mtk_padding_component_ops);
> -return 0;
>  }
>  
>  static const struct of_device_id mtk_padding_driver_dt_match[] = {
> @@ -151,7 +150,7 @@ MODULE_DEVICE_TABLE(of, mtk_padding_driver_dt_match);
>  
>  struct platform_driver mtk_padding_driver = {
>  .probe= mtk_padding_probe,
> -.remove= mtk_padding_remove,
> +.remove_new= mtk_padding_remove,
>  .driver= {
>  .name= "mediatek-disp-padding",
>  .owner= THIS_MODULE,
> -- 
> 2.43.0
>
AngeloGioacchino Del Regno May 16, 2024, 10:12 a.m. UTC | #2
Il 09/04/24 19:02, Uwe Kleine-König ha scritto:
> 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>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> ---
>   drivers/gpu/drm/mediatek/mtk_padding.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_padding.c b/drivers/gpu/drm/mediatek/mtk_padding.c
> index 0d6451c149b6..9f92b720aaae 100644
> --- a/drivers/gpu/drm/mediatek/mtk_padding.c
> +++ b/drivers/gpu/drm/mediatek/mtk_padding.c
> @@ -137,10 +137,9 @@ static int mtk_padding_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> -static int mtk_padding_remove(struct platform_device *pdev)
> +static void mtk_padding_remove(struct platform_device *pdev)
>   {
>   	component_del(&pdev->dev, &mtk_padding_component_ops);
> -	return 0;
>   }
>   
>   static const struct of_device_id mtk_padding_driver_dt_match[] = {
> @@ -151,7 +150,7 @@ MODULE_DEVICE_TABLE(of, mtk_padding_driver_dt_match);
>   
>   struct platform_driver mtk_padding_driver = {
>   	.probe		= mtk_padding_probe,
> -	.remove		= mtk_padding_remove,
> +	.remove_new	= mtk_padding_remove,
>   	.driver		= {
>   		.name	= "mediatek-disp-padding",
>   		.owner	= THIS_MODULE,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_padding.c b/drivers/gpu/drm/mediatek/mtk_padding.c
index 0d6451c149b6..9f92b720aaae 100644
--- a/drivers/gpu/drm/mediatek/mtk_padding.c
+++ b/drivers/gpu/drm/mediatek/mtk_padding.c
@@ -137,10 +137,9 @@  static int mtk_padding_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int mtk_padding_remove(struct platform_device *pdev)
+static void mtk_padding_remove(struct platform_device *pdev)
 {
 	component_del(&pdev->dev, &mtk_padding_component_ops);
-	return 0;
 }
 
 static const struct of_device_id mtk_padding_driver_dt_match[] = {
@@ -151,7 +150,7 @@  MODULE_DEVICE_TABLE(of, mtk_padding_driver_dt_match);
 
 struct platform_driver mtk_padding_driver = {
 	.probe		= mtk_padding_probe,
-	.remove		= mtk_padding_remove,
+	.remove_new	= mtk_padding_remove,
 	.driver		= {
 		.name	= "mediatek-disp-padding",
 		.owner	= THIS_MODULE,