[PATCH 5/5] coresight: tpiu: Convert to platform remove callback returning void

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Apr 23 01:07:02 PDT 2024


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.

Fixes: 3d83d4d4904a ("coresight: tpiu: Move ACPI support from AMBA driver to platform driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 drivers/hwtracing/coresight/coresight-tpiu.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
index 6bf3039839c1..6ecde7d4a25d 100644
--- a/drivers/hwtracing/coresight/coresight-tpiu.c
+++ b/drivers/hwtracing/coresight/coresight-tpiu.c
@@ -285,18 +285,17 @@ static int tpiu_platform_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int tpiu_platform_remove(struct platform_device *pdev)
+static void tpiu_platform_remove(struct platform_device *pdev)
 {
 	struct tpiu_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
 
 	if (WARN_ON(!drvdata))
-		return -ENODEV;
+		return;
 
 	__tpiu_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	if (!IS_ERR_OR_NULL(drvdata->pclk))
 		clk_put(drvdata->pclk);
-	return 0;
 }
 
 #ifdef CONFIG_ACPI
@@ -309,7 +308,7 @@ MODULE_DEVICE_TABLE(acpi, tpiu_acpi_ids);
 
 static struct platform_driver tpiu_platform_driver = {
 	.probe	= tpiu_platform_probe,
-	.remove	= tpiu_platform_remove,
+	.remove_new = tpiu_platform_remove,
 	.driver = {
 		.name			= "coresight-tpiu-platform",
 		.acpi_match_table	= ACPI_PTR(tpiu_acpi_ids),
-- 
2.43.0




More information about the linux-arm-kernel mailing list