diff mbox series

[41/42] crypto: xilinx/zynqmp-aes-gcm - Convert to platform remove callback returning void

Message ID 20231020075521.2121571-85-u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [01/42] crypto: sun4i-ss - Convert to platform remove callback returning void | expand

Commit Message

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

Comments

Michal Simek Oct. 20, 2023, 9:19 a.m. UTC | #1
On 10/20/23 09:56, 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>
> ---
>   drivers/crypto/xilinx/zynqmp-aes-gcm.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/xilinx/zynqmp-aes-gcm.c b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
> index ce335578b759..3c205324b22b 100644
> --- a/drivers/crypto/xilinx/zynqmp-aes-gcm.c
> +++ b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
> @@ -421,12 +421,10 @@ static int zynqmp_aes_aead_probe(struct platform_device *pdev)
>   	return err;
>   }
>   
> -static int zynqmp_aes_aead_remove(struct platform_device *pdev)
> +static void zynqmp_aes_aead_remove(struct platform_device *pdev)
>   {
>   	crypto_engine_exit(aes_drv_ctx.engine);
>   	crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead);
> -
> -	return 0;
>   }
>   
>   static const struct of_device_id zynqmp_aes_dt_ids[] = {
> @@ -437,7 +435,7 @@ MODULE_DEVICE_TABLE(of, zynqmp_aes_dt_ids);
>   
>   static struct platform_driver zynqmp_aes_driver = {
>   	.probe	= zynqmp_aes_aead_probe,
> -	.remove = zynqmp_aes_aead_remove,
> +	.remove_new = zynqmp_aes_aead_remove,
>   	.driver = {
>   		.name		= "zynqmp-aes",
>   		.of_match_table = zynqmp_aes_dt_ids,


Reviewed-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
diff mbox series

Patch

diff --git a/drivers/crypto/xilinx/zynqmp-aes-gcm.c b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
index ce335578b759..3c205324b22b 100644
--- a/drivers/crypto/xilinx/zynqmp-aes-gcm.c
+++ b/drivers/crypto/xilinx/zynqmp-aes-gcm.c
@@ -421,12 +421,10 @@  static int zynqmp_aes_aead_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int zynqmp_aes_aead_remove(struct platform_device *pdev)
+static void zynqmp_aes_aead_remove(struct platform_device *pdev)
 {
 	crypto_engine_exit(aes_drv_ctx.engine);
 	crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead);
-
-	return 0;
 }
 
 static const struct of_device_id zynqmp_aes_dt_ids[] = {
@@ -437,7 +435,7 @@  MODULE_DEVICE_TABLE(of, zynqmp_aes_dt_ids);
 
 static struct platform_driver zynqmp_aes_driver = {
 	.probe	= zynqmp_aes_aead_probe,
-	.remove = zynqmp_aes_aead_remove,
+	.remove_new = zynqmp_aes_aead_remove,
 	.driver = {
 		.name		= "zynqmp-aes",
 		.of_match_table = zynqmp_aes_dt_ids,