diff mbox series

[v2,02/12] drm/etnaviv: Convert to platform remove callback returning void

Message ID 20230801110239.831099-3-u.kleine-koenig@pengutronix.de (mailing list archive)
State Rejected, archived
Headers show
Series drm: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König Aug. 1, 2023, 11:02 a.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 the etnaviv drm driver from always returning zero in
the remove callback to the void returning variant.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 6 ++----
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 ++---
 2 files changed, 4 insertions(+), 7 deletions(-)

Comments

Christian Gmeiner Sept. 9, 2023, 6:49 p.m. UTC | #1
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> schrieb am Di., 1. Aug.
2023, 13:02:

> 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 the etnaviv drm driver from always returning zero in
> the remove callback to the void returning variant.
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>


Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>



---
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 6 ++----
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 ++---
>  2 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index ea55f6b7b744..20305df01b57 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -638,16 +638,14 @@ static int etnaviv_pdev_probe(struct platform_device
> *pdev)
>         return component_master_add_with_match(dev, &etnaviv_master_ops,
> match);
>  }
>
> -static int etnaviv_pdev_remove(struct platform_device *pdev)
> +static void etnaviv_pdev_remove(struct platform_device *pdev)
>  {
>         component_master_del(&pdev->dev, &etnaviv_master_ops);
> -
> -       return 0;
>  }
>
>  static struct platform_driver etnaviv_platform_driver = {
>         .probe      = etnaviv_pdev_probe,
> -       .remove     = etnaviv_pdev_remove,
> +       .remove_new = etnaviv_pdev_remove,
>         .driver     = {
>                 .name   = "etnaviv",
>         },
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index bbc9c54871f4..43426ffe4d77 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1892,11 +1892,10 @@ static int etnaviv_gpu_platform_probe(struct
> platform_device *pdev)
>         return 0;
>  }
>
> -static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
> +static void etnaviv_gpu_platform_remove(struct platform_device *pdev)
>  {
>         component_del(&pdev->dev, &gpu_ops);
>         pm_runtime_disable(&pdev->dev);
> -       return 0;
>  }
>
>  static int etnaviv_gpu_rpm_suspend(struct device *dev)
> @@ -1954,6 +1953,6 @@ struct platform_driver etnaviv_gpu_driver = {
>                 .of_match_table = etnaviv_gpu_match,
>         },
>         .probe = etnaviv_gpu_platform_probe,
> -       .remove = etnaviv_gpu_platform_remove,
> +       .remove_new = etnaviv_gpu_platform_remove,
>         .id_table = gpu_ids,
>  };
> --
> 2.39.2
>
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index ea55f6b7b744..20305df01b57 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -638,16 +638,14 @@  static int etnaviv_pdev_probe(struct platform_device *pdev)
 	return component_master_add_with_match(dev, &etnaviv_master_ops, match);
 }
 
-static int etnaviv_pdev_remove(struct platform_device *pdev)
+static void etnaviv_pdev_remove(struct platform_device *pdev)
 {
 	component_master_del(&pdev->dev, &etnaviv_master_ops);
-
-	return 0;
 }
 
 static struct platform_driver etnaviv_platform_driver = {
 	.probe      = etnaviv_pdev_probe,
-	.remove     = etnaviv_pdev_remove,
+	.remove_new = etnaviv_pdev_remove,
 	.driver     = {
 		.name   = "etnaviv",
 	},
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index bbc9c54871f4..43426ffe4d77 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1892,11 +1892,10 @@  static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
+static void etnaviv_gpu_platform_remove(struct platform_device *pdev)
 {
 	component_del(&pdev->dev, &gpu_ops);
 	pm_runtime_disable(&pdev->dev);
-	return 0;
 }
 
 static int etnaviv_gpu_rpm_suspend(struct device *dev)
@@ -1954,6 +1953,6 @@  struct platform_driver etnaviv_gpu_driver = {
 		.of_match_table = etnaviv_gpu_match,
 	},
 	.probe = etnaviv_gpu_platform_probe,
-	.remove = etnaviv_gpu_platform_remove,
+	.remove_new = etnaviv_gpu_platform_remove,
 	.id_table = gpu_ids,
 };