diff mbox series

[04/52] input: iqs62x-keys - Convert to platform remove callback returning void

Message ID 20230920125829.1478827-5-u.kleine-koenig@pengutronix.de (mailing list archive)
State Mainlined
Commit 0080c3c43dbafb819c91a5fc6a782834badc6527
Headers show
Series input: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König Sept. 20, 2023, 12:57 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/input/keyboard/iqs62x-keys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Jeff LaBundy Sept. 21, 2023, 11:29 a.m. UTC | #1
On Wed, Sep 20, 2023 at 02:57:41PM +0200, 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: Jeff LaBundy <jeff@labundy.com>

> ---
>  drivers/input/keyboard/iqs62x-keys.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/keyboard/iqs62x-keys.c b/drivers/input/keyboard/iqs62x-keys.c
> index 02ceebad7bda..688d61244b5f 100644
> --- a/drivers/input/keyboard/iqs62x-keys.c
> +++ b/drivers/input/keyboard/iqs62x-keys.c
> @@ -310,7 +310,7 @@ static int iqs62x_keys_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int iqs62x_keys_remove(struct platform_device *pdev)
> +static void iqs62x_keys_remove(struct platform_device *pdev)
>  {
>  	struct iqs62x_keys_private *iqs62x_keys = platform_get_drvdata(pdev);
>  	int ret;
> @@ -319,8 +319,6 @@ static int iqs62x_keys_remove(struct platform_device *pdev)
>  						 &iqs62x_keys->notifier);
>  	if (ret)
>  		dev_err(&pdev->dev, "Failed to unregister notifier: %d\n", ret);
> -
> -	return 0;
>  }
>  
>  static struct platform_driver iqs62x_keys_platform_driver = {
> @@ -328,7 +326,7 @@ static struct platform_driver iqs62x_keys_platform_driver = {
>  		.name = "iqs62x-keys",
>  	},
>  	.probe = iqs62x_keys_probe,
> -	.remove = iqs62x_keys_remove,
> +	.remove_new = iqs62x_keys_remove,
>  };
>  module_platform_driver(iqs62x_keys_platform_driver);
>  
> -- 
> 2.40.1
>
diff mbox series

Patch

diff --git a/drivers/input/keyboard/iqs62x-keys.c b/drivers/input/keyboard/iqs62x-keys.c
index 02ceebad7bda..688d61244b5f 100644
--- a/drivers/input/keyboard/iqs62x-keys.c
+++ b/drivers/input/keyboard/iqs62x-keys.c
@@ -310,7 +310,7 @@  static int iqs62x_keys_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int iqs62x_keys_remove(struct platform_device *pdev)
+static void iqs62x_keys_remove(struct platform_device *pdev)
 {
 	struct iqs62x_keys_private *iqs62x_keys = platform_get_drvdata(pdev);
 	int ret;
@@ -319,8 +319,6 @@  static int iqs62x_keys_remove(struct platform_device *pdev)
 						 &iqs62x_keys->notifier);
 	if (ret)
 		dev_err(&pdev->dev, "Failed to unregister notifier: %d\n", ret);
-
-	return 0;
 }
 
 static struct platform_driver iqs62x_keys_platform_driver = {
@@ -328,7 +326,7 @@  static struct platform_driver iqs62x_keys_platform_driver = {
 		.name = "iqs62x-keys",
 	},
 	.probe = iqs62x_keys_probe,
-	.remove = iqs62x_keys_remove,
+	.remove_new = iqs62x_keys_remove,
 };
 module_platform_driver(iqs62x_keys_platform_driver);