2024-04-09 17:05:21

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 1/4] drm/imagination: Convert to platform remove callback returning void

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]>
---
drivers/gpu/drm/imagination/pvr_drv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
index 5c3b2d58d766..1a0cb7aa9cea 100644
--- a/drivers/gpu/drm/imagination/pvr_drv.c
+++ b/drivers/gpu/drm/imagination/pvr_drv.c
@@ -1451,8 +1451,7 @@ pvr_probe(struct platform_device *plat_dev)
return err;
}

-static int
-pvr_remove(struct platform_device *plat_dev)
+static void pvr_remove(struct platform_device *plat_dev)
{
struct drm_device *drm_dev = platform_get_drvdata(plat_dev);
struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
@@ -1469,8 +1468,6 @@ pvr_remove(struct platform_device *plat_dev)
pvr_watchdog_fini(pvr_dev);
pvr_queue_device_fini(pvr_dev);
pvr_context_device_fini(pvr_dev);
-
- return 0;
}

static const struct of_device_id dt_match[] = {
@@ -1485,7 +1482,7 @@ static const struct dev_pm_ops pvr_pm_ops = {

static struct platform_driver pvr_driver = {
.probe = pvr_probe,
- .remove = pvr_remove,
+ .remove_new = pvr_remove,
.driver = {
.name = PVR_DRIVER_NAME,
.pm = &pvr_pm_ops,
--
2.43.0



2024-04-16 19:19:13

by Matt Coster

[permalink] [raw]
Subject: Re: [PATCH 1/4] drm/imagination: Convert to platform remove callback returning void

On 09/04/2024 10:02, 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]>

Reviewed-by: Matt Coster <[email protected]>

> ---
> drivers/gpu/drm/imagination/pvr_drv.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
> index 5c3b2d58d766..1a0cb7aa9cea 100644
> --- a/drivers/gpu/drm/imagination/pvr_drv.c
> +++ b/drivers/gpu/drm/imagination/pvr_drv.c
> @@ -1451,8 +1451,7 @@ pvr_probe(struct platform_device *plat_dev)
> return err;
> }
>
> -static int
> -pvr_remove(struct platform_device *plat_dev)
> +static void pvr_remove(struct platform_device *plat_dev)
> {
> struct drm_device *drm_dev = platform_get_drvdata(plat_dev);
> struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
> @@ -1469,8 +1468,6 @@ pvr_remove(struct platform_device *plat_dev)
> pvr_watchdog_fini(pvr_dev);
> pvr_queue_device_fini(pvr_dev);
> pvr_context_device_fini(pvr_dev);
> -
> - return 0;
> }
>
> static const struct of_device_id dt_match[] = {
> @@ -1485,7 +1482,7 @@ static const struct dev_pm_ops pvr_pm_ops = {
>
> static struct platform_driver pvr_driver = {
> .probe = pvr_probe,
> - .remove = pvr_remove,
> + .remove_new = pvr_remove,
> .driver = {
> .name = PVR_DRIVER_NAME,
> .pm = &pvr_pm_ops,


Attachments:
OpenPGP_signature.asc (243.00 B)
OpenPGP digital signature

2024-04-23 08:45:11

by Matt Coster

[permalink] [raw]
Subject: Re: [PATCH 1/4] drm/imagination: Convert to platform remove callback returning void

On 09/04/2024 18:02, 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]>

Acked-by: Matt Coster <[email protected]>

> ---
> drivers/gpu/drm/imagination/pvr_drv.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
> index 5c3b2d58d766..1a0cb7aa9cea 100644
> --- a/drivers/gpu/drm/imagination/pvr_drv.c
> +++ b/drivers/gpu/drm/imagination/pvr_drv.c
> @@ -1451,8 +1451,7 @@ pvr_probe(struct platform_device *plat_dev)
> return err;
> }
>
> -static int
> -pvr_remove(struct platform_device *plat_dev)
> +static void pvr_remove(struct platform_device *plat_dev)
> {
> struct drm_device *drm_dev = platform_get_drvdata(plat_dev);
> struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
> @@ -1469,8 +1468,6 @@ pvr_remove(struct platform_device *plat_dev)
> pvr_watchdog_fini(pvr_dev);
> pvr_queue_device_fini(pvr_dev);
> pvr_context_device_fini(pvr_dev);
> -
> - return 0;
> }
>
> static const struct of_device_id dt_match[] = {
> @@ -1485,7 +1482,7 @@ static const struct dev_pm_ops pvr_pm_ops = {
>
> static struct platform_driver pvr_driver = {
> .probe = pvr_probe,
> - .remove = pvr_remove,
> + .remove_new = pvr_remove,
> .driver = {
> .name = PVR_DRIVER_NAME,
> .pm = &pvr_pm_ops,


Attachments:
OpenPGP_0x747F0A9036F90DFA.asc (1.77 kB)
OpenPGP public key
OpenPGP_signature.asc (243.00 B)
OpenPGP digital signature
Download all attachments