PCI: host-generic: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 20 Oct 2023 09:21:07 +0000 (11:21 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 20 Nov 2023 21:53:14 +0000 (15:53 -0600)
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 (mostly) ignored
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.

pci_host_common_remove() returned zero unconditionally. With that converted
to return void instead, the generic pci host driver can be switched to
.remove_new() trivially.

Link: https://lore.kernel.org/r/20231020092107.2148311-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will@kernel.org>
drivers/pci/controller/pci-host-common.c
drivers/pci/controller/pci-host-generic.c
include/linux/pci-ecam.h

index 6be3266cd7b5b2f803c60a71686ce8ffbf20be6d..45b71806182d2b8f9ae7cd876465684f6418abca 100644 (file)
@@ -85,7 +85,7 @@ int pci_host_common_probe(struct platform_device *pdev)
 }
 EXPORT_SYMBOL_GPL(pci_host_common_probe);
 
-int pci_host_common_remove(struct platform_device *pdev)
+void pci_host_common_remove(struct platform_device *pdev)
 {
        struct pci_host_bridge *bridge = platform_get_drvdata(pdev);
 
@@ -93,8 +93,6 @@ int pci_host_common_remove(struct platform_device *pdev)
        pci_stop_root_bus(bridge->bus);
        pci_remove_root_bus(bridge->bus);
        pci_unlock_rescan_remove();
-
-       return 0;
 }
 EXPORT_SYMBOL_GPL(pci_host_common_remove);
 
index 63865aeb636b88d3f39e28095cb219dbc4522358..41cb6a057f6e4578c6f3460e80c8aaa677e9c0a4 100644 (file)
@@ -82,7 +82,7 @@ static struct platform_driver gen_pci_driver = {
                .of_match_table = gen_pci_of_match,
        },
        .probe = pci_host_common_probe,
-       .remove = pci_host_common_remove,
+       .remove_new = pci_host_common_remove,
 };
 module_platform_driver(gen_pci_driver);
 
index 6b1301e2498e9e163c6e9a0525e49afa226bffea..3a4860bd27586587cb23e7d6f84f63efcf6f2fc6 100644 (file)
@@ -93,6 +93,6 @@ extern const struct pci_ecam_ops loongson_pci_ecam_ops; /* Loongson PCIe */
 #if IS_ENABLED(CONFIG_PCI_HOST_COMMON)
 /* for DT-based PCI controllers that support ECAM */
 int pci_host_common_probe(struct platform_device *pdev);
-int pci_host_common_remove(struct platform_device *pdev);
+void pci_host_common_remove(struct platform_device *pdev);
 #endif
 #endif