[12/13] irqchip/stm32-exti: Convert to platform remove callback returning void

Message ID ac551b89025bafadce05102b94596f8cd3564a32.1703284359.git.u.kleine-koenig@pengutronix.de
State New
Headers
Series irqchip: Convert to platform remove callback returning void |

Commit Message

Uwe Kleine-König Dec. 22, 2023, 10:50 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/irqchip/irq-stm32-exti.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Antonio Borneo Dec. 24, 2023, 11:59 a.m. UTC | #1
On Fri, 2023-12-22 at 23:50 +0100, 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: Antonio Borneo <antonio.borneo@foss.st.com>

Regards,
Antonio

> ---
>  drivers/irqchip/irq-stm32-exti.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
> index 971240e2e31b..c61a97caafc9 100644
> --- a/drivers/irqchip/irq-stm32-exti.c
> +++ b/drivers/irqchip/irq-stm32-exti.c
> @@ -898,10 +898,9 @@ static void stm32_exti_remove_irq(void *data)
>         irq_domain_remove(domain);
>  }
>  
> -static int stm32_exti_remove(struct platform_device *pdev)
> +static void stm32_exti_remove(struct platform_device *pdev)
>  {
>         stm32_exti_h_syscore_deinit();
> -       return 0;
>  }
>  
>  static int stm32_exti_probe(struct platform_device *pdev)
> @@ -991,7 +990,7 @@ MODULE_DEVICE_TABLE(of, stm32_exti_ids);
>  
>  static struct platform_driver stm32_exti_driver = {
>         .probe          = stm32_exti_probe,
> -       .remove         = stm32_exti_remove,
> +       .remove_new     = stm32_exti_remove,
>         .driver         = {
>                 .name   = "stm32_exti",
>                 .of_match_table = stm32_exti_ids,
  

Patch

diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 971240e2e31b..c61a97caafc9 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -898,10 +898,9 @@  static void stm32_exti_remove_irq(void *data)
 	irq_domain_remove(domain);
 }
 
-static int stm32_exti_remove(struct platform_device *pdev)
+static void stm32_exti_remove(struct platform_device *pdev)
 {
 	stm32_exti_h_syscore_deinit();
-	return 0;
 }
 
 static int stm32_exti_probe(struct platform_device *pdev)
@@ -991,7 +990,7 @@  MODULE_DEVICE_TABLE(of, stm32_exti_ids);
 
 static struct platform_driver stm32_exti_driver = {
 	.probe		= stm32_exti_probe,
-	.remove		= stm32_exti_remove,
+	.remove_new	= stm32_exti_remove,
 	.driver		= {
 		.name	= "stm32_exti",
 		.of_match_table = stm32_exti_ids,