diff mbox series

[09/21] EDAC/highbank_mc: Convert to platform remove callback returning void

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

Commit Message

Uwe Kleine-König Oct. 4, 2023, 1:12 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/edac/highbank_mc_edac.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Andre Przywara Nov. 20, 2023, 5:45 p.m. UTC | #1
On Wed,  4 Oct 2023 15:12:42 +0200
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 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: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  drivers/edac/highbank_mc_edac.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/edac/highbank_mc_edac.c b/drivers/edac/highbank_mc_edac.c
> index a0c04a7f95e9..1c5b888ab11d 100644
> --- a/drivers/edac/highbank_mc_edac.c
> +++ b/drivers/edac/highbank_mc_edac.c
> @@ -251,18 +251,17 @@ static int highbank_mc_probe(struct platform_device *pdev)
>  	return res;
>  }
>  
> -static int highbank_mc_remove(struct platform_device *pdev)
> +static void highbank_mc_remove(struct platform_device *pdev)
>  {
>  	struct mem_ctl_info *mci = platform_get_drvdata(pdev);
>  
>  	edac_mc_del_mc(&pdev->dev);
>  	edac_mc_free(mci);
> -	return 0;
>  }
>  
>  static struct platform_driver highbank_mc_edac_driver = {
>  	.probe = highbank_mc_probe,
> -	.remove = highbank_mc_remove,
> +	.remove_new = highbank_mc_remove,
>  	.driver = {
>  		.name = "hb_mc_edac",
>  		.of_match_table = hb_ddr_ctrl_of_match,
diff mbox series

Patch

diff --git a/drivers/edac/highbank_mc_edac.c b/drivers/edac/highbank_mc_edac.c
index a0c04a7f95e9..1c5b888ab11d 100644
--- a/drivers/edac/highbank_mc_edac.c
+++ b/drivers/edac/highbank_mc_edac.c
@@ -251,18 +251,17 @@  static int highbank_mc_probe(struct platform_device *pdev)
 	return res;
 }
 
-static int highbank_mc_remove(struct platform_device *pdev)
+static void highbank_mc_remove(struct platform_device *pdev)
 {
 	struct mem_ctl_info *mci = platform_get_drvdata(pdev);
 
 	edac_mc_del_mc(&pdev->dev);
 	edac_mc_free(mci);
-	return 0;
 }
 
 static struct platform_driver highbank_mc_edac_driver = {
 	.probe = highbank_mc_probe,
-	.remove = highbank_mc_remove,
+	.remove_new = highbank_mc_remove,
 	.driver = {
 		.name = "hb_mc_edac",
 		.of_match_table = hb_ddr_ctrl_of_match,