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

From
Alex Elder <hidden>
Date
2023-11-17 14:24:10
Reply to
Uwe Kleine-König, 2023-11-17
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 <redacted>
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

quoted hunk ↗ jump to hunk
---
  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,
  
Thread (23 messages) 23 messages, 7 authors, last reply 2023-11-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help