2023-12-27 16:27:23

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 08/11] firmware: stratix10-rsu: 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/firmware/stratix10-rsu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
index 4f7a7abada48..e20cee9c2d32 100644
--- a/drivers/firmware/stratix10-rsu.c
+++ b/drivers/firmware/stratix10-rsu.c
@@ -793,17 +793,16 @@ static int stratix10_rsu_probe(struct platform_device *pdev)
return ret;
}

-static int stratix10_rsu_remove(struct platform_device *pdev)
+static void stratix10_rsu_remove(struct platform_device *pdev)
{
struct stratix10_rsu_priv *priv = platform_get_drvdata(pdev);

stratix10_svc_free_channel(priv->chan);
- return 0;
}

static struct platform_driver stratix10_rsu_driver = {
.probe = stratix10_rsu_probe,
- .remove = stratix10_rsu_remove,
+ .remove_new = stratix10_rsu_remove,
.driver = {
.name = "stratix10-rsu",
.dev_groups = rsu_groups,
--
2.43.0



2024-01-04 12:24:02

by Dinh Nguyen

[permalink] [raw]
Subject: Re: [PATCH 08/11] firmware: stratix10-rsu: Convert to platform remove callback returning void

On 12/27/23 10:26, 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]>
> ---
> drivers/firmware/stratix10-rsu.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
> index 4f7a7abada48..e20cee9c2d32 100644
> --- a/drivers/firmware/stratix10-rsu.c
> +++ b/drivers/firmware/stratix10-rsu.c
> @@ -793,17 +793,16 @@ static int stratix10_rsu_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static int stratix10_rsu_remove(struct platform_device *pdev)
> +static void stratix10_rsu_remove(struct platform_device *pdev)
> {
> struct stratix10_rsu_priv *priv = platform_get_drvdata(pdev);
>
> stratix10_svc_free_channel(priv->chan);
> - return 0;
> }
>
> static struct platform_driver stratix10_rsu_driver = {
> .probe = stratix10_rsu_probe,
> - .remove = stratix10_rsu_remove,
> + .remove_new = stratix10_rsu_remove,
> .driver = {
> .name = "stratix10-rsu",
> .dev_groups = rsu_groups,

Acked-by: Dinh Nguyen <[email protected]>