diff mbox series

[06/13] irqchip/madera: Convert to platform remove callback returning void

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

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-madera.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Richard Fitzgerald Jan. 4, 2024, 11:56 a.m. UTC | #1
On 22/12/23 22:50, 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/irqchip/irq-madera.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-madera.c b/drivers/irqchip/irq-madera.c
> index 3eb1f8cdf674..b424c0a327f7 100644
> --- a/drivers/irqchip/irq-madera.c
> +++ b/drivers/irqchip/irq-madera.c
> @@ -222,7 +222,7 @@ static int madera_irq_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> -static int madera_irq_remove(struct platform_device *pdev)
> +static void madera_irq_remove(struct platform_device *pdev)
>   {
>   	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
>   
> @@ -232,13 +232,11 @@ static int madera_irq_remove(struct platform_device *pdev)
>   	 */
>   	madera->irq_dev = NULL;
>   	regmap_del_irq_chip(madera->irq, madera->irq_data);
> -
> -	return 0;
>   }
>   
>   static struct platform_driver madera_irq_driver = {
>   	.probe	= &madera_irq_probe,
> -	.remove = &madera_irq_remove,
> +	.remove_new = madera_irq_remove,
>   	.driver = {
>   		.name	= "madera-irq",
>   		.pm	= &madera_irq_pm_ops,

Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-madera.c b/drivers/irqchip/irq-madera.c
index 3eb1f8cdf674..b424c0a327f7 100644
--- a/drivers/irqchip/irq-madera.c
+++ b/drivers/irqchip/irq-madera.c
@@ -222,7 +222,7 @@  static int madera_irq_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int madera_irq_remove(struct platform_device *pdev)
+static void madera_irq_remove(struct platform_device *pdev)
 {
 	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
 
@@ -232,13 +232,11 @@  static int madera_irq_remove(struct platform_device *pdev)
 	 */
 	madera->irq_dev = NULL;
 	regmap_del_irq_chip(madera->irq, madera->irq_data);
-
-	return 0;
 }
 
 static struct platform_driver madera_irq_driver = {
 	.probe	= &madera_irq_probe,
-	.remove = &madera_irq_remove,
+	.remove_new = madera_irq_remove,
 	.driver = {
 		.name	= "madera-irq",
 		.pm	= &madera_irq_pm_ops,