diff mbox series

[08/42] crypto: atmel-aes - Convert to platform remove callback returning void

Message ID 20231020075521.2121571-52-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König Oct. 20, 2023, 7:55 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/crypto/atmel-aes.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Hari Prasath Gujulan Elango Oct. 20, 2023, 8:49 a.m. UTC | #1
On 20/10/23 1:25 pm, Uwe Kleine-König wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> 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>

This and the two consecutive Atmel/Microchip specific patches looks good 
to me.

Reviewed-by: Hari Prasath Gujulan Elango <hari.prasathge@microchip.com>

> ---
>   drivers/crypto/atmel-aes.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
> index 55b5f577b01c..d1d93e897892 100644
> --- a/drivers/crypto/atmel-aes.c
> +++ b/drivers/crypto/atmel-aes.c
> @@ -2648,7 +2648,7 @@ static int atmel_aes_probe(struct platform_device *pdev)
>          return err;
>   }
> 
> -static int atmel_aes_remove(struct platform_device *pdev)
> +static void atmel_aes_remove(struct platform_device *pdev)
>   {
>          struct atmel_aes_dev *aes_dd;
> 
> @@ -2667,13 +2667,11 @@ static int atmel_aes_remove(struct platform_device *pdev)
>          atmel_aes_buff_cleanup(aes_dd);
> 
>          clk_unprepare(aes_dd->iclk);
> -
> -       return 0;
>   }
> 
>   static struct platform_driver atmel_aes_driver = {
>          .probe          = atmel_aes_probe,
> -       .remove         = atmel_aes_remove,
> +       .remove_new     = atmel_aes_remove,
>          .driver         = {
>                  .name   = "atmel_aes",
>                  .of_match_table = atmel_aes_dt_ids,
> --
> 2.42.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff mbox series

Patch

diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
index 55b5f577b01c..d1d93e897892 100644
--- a/drivers/crypto/atmel-aes.c
+++ b/drivers/crypto/atmel-aes.c
@@ -2648,7 +2648,7 @@  static int atmel_aes_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int atmel_aes_remove(struct platform_device *pdev)
+static void atmel_aes_remove(struct platform_device *pdev)
 {
 	struct atmel_aes_dev *aes_dd;
 
@@ -2667,13 +2667,11 @@  static int atmel_aes_remove(struct platform_device *pdev)
 	atmel_aes_buff_cleanup(aes_dd);
 
 	clk_unprepare(aes_dd->iclk);
-
-	return 0;
 }
 
 static struct platform_driver atmel_aes_driver = {
 	.probe		= atmel_aes_probe,
-	.remove		= atmel_aes_remove,
+	.remove_new	= atmel_aes_remove,
 	.driver		= {
 		.name	= "atmel_aes",
 		.of_match_table = atmel_aes_dt_ids,