diff mbox series

[16/14] power: reset: at91-sama5d2_shdwc: Convert to platform remove callback returning void

Message ID 20231105094712.3706799-4-u.kleine-koenig@pengutronix.de (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: reset: Drop platform_driver_probe() and convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König Nov. 5, 2023, 9:47 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 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/power/reset/at91-sama5d2_shdwc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Claudiu Nov. 8, 2023, 6:56 a.m. UTC | #1
On 05.11.2023 11:47, 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 <u.kleine-koenig@pengutronix.de>

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>

> ---
>  drivers/power/reset/at91-sama5d2_shdwc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
> index ef8add623363..af95c7b39cb3 100644
> --- a/drivers/power/reset/at91-sama5d2_shdwc.c
> +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
> @@ -421,7 +421,7 @@ static int at91_shdwc_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int at91_shdwc_remove(struct platform_device *pdev)
> +static void at91_shdwc_remove(struct platform_device *pdev)
>  {
>  	struct shdwc *shdw = platform_get_drvdata(pdev);
>  
> @@ -437,13 +437,11 @@ static int at91_shdwc_remove(struct platform_device *pdev)
>  	iounmap(shdw->pmc_base);
>  
>  	clk_disable_unprepare(shdw->sclk);
> -
> -	return 0;
>  }
>  
>  static struct platform_driver at91_shdwc_driver = {
>  	.probe = at91_shdwc_probe,
> -	.remove = at91_shdwc_remove,
> +	.remove_new = at91_shdwc_remove,
>  	.driver = {
>  		.name = "at91-shdwc",
>  		.of_match_table = at91_shdwc_of_match,
diff mbox series

Patch

diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
index ef8add623363..af95c7b39cb3 100644
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -421,7 +421,7 @@  static int at91_shdwc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int at91_shdwc_remove(struct platform_device *pdev)
+static void at91_shdwc_remove(struct platform_device *pdev)
 {
 	struct shdwc *shdw = platform_get_drvdata(pdev);
 
@@ -437,13 +437,11 @@  static int at91_shdwc_remove(struct platform_device *pdev)
 	iounmap(shdw->pmc_base);
 
 	clk_disable_unprepare(shdw->sclk);
-
-	return 0;
 }
 
 static struct platform_driver at91_shdwc_driver = {
 	.probe = at91_shdwc_probe,
-	.remove = at91_shdwc_remove,
+	.remove_new = at91_shdwc_remove,
 	.driver = {
 		.name = "at91-shdwc",
 		.of_match_table = at91_shdwc_of_match,