diff mbox series

[net-next,02/10] net: ipa: Convert to platform remove callback returning void

Message ID 20231117095922.876489-3-u.kleine-koenig@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net*: Convert to platform remove callback returning void | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1127 this patch: 1127
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1154 this patch: 1154
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1154 this patch: 1154
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Uwe Kleine-König Nov. 17, 2023, 9:59 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/net/ipa/ipa_main.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

Comments

Alex Elder Nov. 17, 2023, 2:24 p.m. UTC | #1
On 11/17/23 3:59 AM, 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>

To be clear, this patch can't proceed until the previous
one is resolved.  Once it is, this should be fine.

Sorry for not just doing it now.  I like what you're doing,
I just don't have time to spend at the moment for the
review this will require.

					-Alex


> ---
>   drivers/net/ipa/ipa_main.c | 17 +++--------------
>   1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
> index 60e4f590f5de..2c769b85a2cd 100644
> --- a/drivers/net/ipa/ipa_main.c
> +++ b/drivers/net/ipa/ipa_main.c
> @@ -936,7 +936,7 @@ static int ipa_probe(struct platform_device *pdev)
>   	return ret;
>   }
>   
> -static int ipa_remove(struct platform_device *pdev)
> +static void ipa_remove(struct platform_device *pdev)
>   {
>   	struct ipa *ipa = dev_get_drvdata(&pdev->dev);
>   	struct ipa_power *power = ipa->power;
> @@ -979,17 +979,6 @@ static int ipa_remove(struct platform_device *pdev)
>   	ipa_power_exit(power);
>   
>   	dev_info(dev, "IPA driver removed");
> -
> -	return 0;
> -}
> -
> -static void ipa_shutdown(struct platform_device *pdev)
> -{
> -	int ret;
> -
> -	ret = ipa_remove(pdev);
> -	if (ret)
> -		dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret);
>   }
>   
>   static const struct attribute_group *ipa_attribute_groups[] = {
> @@ -1002,8 +991,8 @@ static const struct attribute_group *ipa_attribute_groups[] = {
>   
>   static struct platform_driver ipa_driver = {
>   	.probe		= ipa_probe,
> -	.remove		= ipa_remove,
> -	.shutdown	= ipa_shutdown,
> +	.remove_new	= ipa_remove,
> +	.shutdown	= ipa_remove,
>   	.driver	= {
>   		.name		= "ipa",
>   		.pm		= &ipa_pm_ops,
diff mbox series

Patch

diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 60e4f590f5de..2c769b85a2cd 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -936,7 +936,7 @@  static int ipa_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int ipa_remove(struct platform_device *pdev)
+static void ipa_remove(struct platform_device *pdev)
 {
 	struct ipa *ipa = dev_get_drvdata(&pdev->dev);
 	struct ipa_power *power = ipa->power;
@@ -979,17 +979,6 @@  static int ipa_remove(struct platform_device *pdev)
 	ipa_power_exit(power);
 
 	dev_info(dev, "IPA driver removed");
-
-	return 0;
-}
-
-static void ipa_shutdown(struct platform_device *pdev)
-{
-	int ret;
-
-	ret = ipa_remove(pdev);
-	if (ret)
-		dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret);
 }
 
 static const struct attribute_group *ipa_attribute_groups[] = {
@@ -1002,8 +991,8 @@  static const struct attribute_group *ipa_attribute_groups[] = {
 
 static struct platform_driver ipa_driver = {
 	.probe		= ipa_probe,
-	.remove		= ipa_remove,
-	.shutdown	= ipa_shutdown,
+	.remove_new	= ipa_remove,
+	.shutdown	= ipa_remove,
 	.driver	= {
 		.name		= "ipa",
 		.pm		= &ipa_pm_ops,