coresight: tmc: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 23 Apr 2024 08:07:01 +0000 (10:07 +0200)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Thu, 25 Apr 2024 09:07:16 +0000 (10:07 +0100)
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: 70750e257aab ("coresight: tmc: Move ACPI support from AMBA driver to platform driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/3cf26d85a8d45f0efb07e07f3307a1b435ebf61e.1713858615.git.u.kleine-koenig@pengutronix.de
drivers/hwtracing/coresight/coresight-tmc-core.c

index c9aaf3567565ec42f4b50caa57273bfef0c515a3..4b50d043ce0446261f2405a9f36c2f031734ecdc 100644 (file)
@@ -659,18 +659,17 @@ static int tmc_platform_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int tmc_platform_remove(struct platform_device *pdev)
+static void tmc_platform_remove(struct platform_device *pdev)
 {
        struct tmc_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
 
        if (WARN_ON(!drvdata))
-               return -ENODEV;
+               return;
 
        __tmc_remove(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        if (!IS_ERR_OR_NULL(drvdata->pclk))
                clk_put(drvdata->pclk);
-       return 0;
 }
 
 #ifdef CONFIG_PM
@@ -708,7 +707,7 @@ MODULE_DEVICE_TABLE(acpi, tmc_acpi_ids);
 
 static struct platform_driver tmc_platform_driver = {
        .probe  = tmc_platform_probe,
-       .remove = tmc_platform_remove,
+       .remove_new = tmc_platform_remove,
        .driver = {
                .name                   = "coresight-tmc-platform",
                .acpi_match_table       = ACPI_PTR(tmc_acpi_ids),