Skip to contentSkip to conversation

x86: platform: Convert to platform remove callback returning void

PATCH New Uwe Kleine-König 1 participant 4 messages Apr 10, 2024 x86

lore
Share & tools
lore
#0 lore raw

cover x86: platform: Convert to platform remove callback returning void

Hello,

this series converts all platform drivers below arch/x86/ to not use struct platform_device::remove() any more. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All conversations are trivial, because the driver's .remove() callbacks returned zero unconditionally.

I don't know how maintenance of these drivers is organized, but there are no interdependencies between these patches, so they can be applied independently if needed. This is merge window material.

Best regards
Uwe

Uwe Kleine-König (3):
x86: platform: iris: Convert to platform remove callback returning
void
x86: platform: olpc-x01-pm: Convert to platform remove callback
returning void
x86: platform: olpc-xo1-sci: Convert to platform remove callback
returning void

 arch/x86/platform/iris/iris.c         | 5 ++---
 arch/x86/platform/olpc/olpc-xo1-pm.c  | 7 +++----
 arch/x86/platform/olpc/olpc-xo1-sci.c | 5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)

base-commit: 6ebf211bb11dfc004a2ff73a9de5386fa309c430

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 x86: platform: iris: Convert to platform remove callback returning void

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.

---
 arch/x86/platform/iris/iris.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/platform/iris/iris.c +2 -3
index b42bfdab01a9..c5f3bbdbdcfe 100644
@@ -62,11 +62,10 @@ static int iris_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int iris_remove(struct platform_device *pdev)
+static void iris_remove(struct platform_device *pdev)
 {
 	pm_power_off = old_pm_power_off;
 	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
-	return 0;
 }
 
 static struct platform_driver iris_driver = {
@@ -74,7 +73,7 @@ static struct platform_driver iris_driver = {
 		.name   = "iris",
 	},
 	.probe          = iris_probe,
-	.remove         = iris_remove,
+	.remove_new     = iris_remove,
 };
 
 static struct resource iris_resources[] = {
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 x86: platform: olpc-x01-pm: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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.

---
 arch/x86/platform/olpc/olpc-xo1-pm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/platform/olpc/olpc-xo1-pm.c +3 -4
index f067ac780ba7..6a9c42de74e7 100644
@@ -144,7 +144,7 @@ static int xo1_pm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int xo1_pm_remove(struct platform_device *pdev)
+static void xo1_pm_remove(struct platform_device *pdev)
 {
 	if (strcmp(pdev->name, "cs5535-pms") == 0)
 		pms_base = 0;
@@ -152,7 +152,6 @@ static int xo1_pm_remove(struct platform_device *pdev)
 		acpi_base = 0;
 
 	pm_power_off = NULL;
-	return 0;
 }
 
 static struct platform_driver cs5535_pms_driver = {
@@ -160,7 +159,7 @@ static struct platform_driver cs5535_pms_driver = {
 		.name = "cs5535-pms",
 	},
 	.probe = xo1_pm_probe,
-	.remove = xo1_pm_remove,
+	.remove_new = xo1_pm_remove,
 };
 
 static struct platform_driver cs5535_acpi_driver = {
@@ -168,7 +167,7 @@ static struct platform_driver cs5535_acpi_driver = {
 		.name = "olpc-xo1-pm-acpi",
 	},
 	.probe = xo1_pm_probe,
-	.remove = xo1_pm_remove,
+	.remove_new = xo1_pm_remove,
 };
 
 static int __init xo1_pm_init(void)
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 x86: platform: olpc-xo1-sci: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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.

---
 arch/x86/platform/olpc/olpc-xo1-sci.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/platform/olpc/olpc-xo1-sci.c +2 -3
index 89f25af4b3c3..46d42ff6e18a 100644
@@ -598,7 +598,7 @@ static int xo1_sci_probe(struct platform_device *pdev)
 	return r;
 }
 
-static int xo1_sci_remove(struct platform_device *pdev)
+static void xo1_sci_remove(struct platform_device *pdev)
 {
 	free_irq(sci_irq, pdev);
 	cancel_work_sync(&sci_work);
@@ -608,7 +608,6 @@ static int xo1_sci_remove(struct platform_device *pdev)
 	free_ebook_switch();
 	free_power_button();
 	acpi_base = 0;
-	return 0;
 }
 
 static struct platform_driver xo1_sci_driver = {
@@ -617,7 +616,7 @@ static struct platform_driver xo1_sci_driver = {
 		.dev_groups = lid_groups,
 	},
 	.probe = xo1_sci_probe,
-	.remove = xo1_sci_remove,
+	.remove_new = xo1_sci_remove,
 	.suspend = xo1_sci_suspend,
 	.resume = xo1_sci_resume,
 };
Signature · 1 line
2.43.0