Skip to content

Commit 221879c

Browse files
Uwe Kleine-Königkwilczynski
authored andcommitted
PCI: dwc: 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 (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. Trivially convert the dwc drivers from always returning zero in the remove callback to the void returning variant. [kwilczynski: commit log] Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Acked-by: Serge Semin <[email protected]>
1 parent c86f4bd commit 221879c

File tree

5 files changed

+12
-22
lines changed

5 files changed

+12
-22
lines changed

drivers/pci/controller/dwc/pcie-bt1.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,11 @@ static int bt1_pcie_probe(struct platform_device *pdev)
617617
return bt1_pcie_add_port(btpci);
618618
}
619619

620-
static int bt1_pcie_remove(struct platform_device *pdev)
620+
static void bt1_pcie_remove(struct platform_device *pdev)
621621
{
622622
struct bt1_pcie *btpci = platform_get_drvdata(pdev);
623623

624624
bt1_pcie_del_port(btpci);
625-
626-
return 0;
627625
}
628626

629627
static const struct of_device_id bt1_pcie_of_match[] = {
@@ -634,7 +632,7 @@ MODULE_DEVICE_TABLE(of, bt1_pcie_of_match);
634632

635633
static struct platform_driver bt1_pcie_driver = {
636634
.probe = bt1_pcie_probe,
637-
.remove = bt1_pcie_remove,
635+
.remove_new = bt1_pcie_remove,
638636
.driver = {
639637
.name = "bt1-pcie",
640638
.of_match_table = bt1_pcie_of_match,

drivers/pci/controller/dwc/pcie-histb.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,14 @@ static int histb_pcie_probe(struct platform_device *pdev)
421421
return 0;
422422
}
423423

424-
static int histb_pcie_remove(struct platform_device *pdev)
424+
static void histb_pcie_remove(struct platform_device *pdev)
425425
{
426426
struct histb_pcie *hipcie = platform_get_drvdata(pdev);
427427

428428
histb_pcie_host_disable(hipcie);
429429

430430
if (hipcie->phy)
431431
phy_exit(hipcie->phy);
432-
433-
return 0;
434432
}
435433

436434
static const struct of_device_id histb_pcie_of_match[] = {
@@ -441,7 +439,7 @@ MODULE_DEVICE_TABLE(of, histb_pcie_of_match);
441439

442440
static struct platform_driver histb_pcie_platform_driver = {
443441
.probe = histb_pcie_probe,
444-
.remove = histb_pcie_remove,
442+
.remove_new = histb_pcie_remove,
445443
.driver = {
446444
.name = "histb-pcie",
447445
.of_match_table = histb_pcie_of_match,

drivers/pci/controller/dwc/pcie-intel-gw.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,13 @@ static void __intel_pcie_remove(struct intel_pcie *pcie)
340340
phy_exit(pcie->phy);
341341
}
342342

343-
static int intel_pcie_remove(struct platform_device *pdev)
343+
static void intel_pcie_remove(struct platform_device *pdev)
344344
{
345345
struct intel_pcie *pcie = platform_get_drvdata(pdev);
346346
struct dw_pcie_rp *pp = &pcie->pci.pp;
347347

348348
dw_pcie_host_deinit(pp);
349349
__intel_pcie_remove(pcie);
350-
351-
return 0;
352350
}
353351

354352
static int intel_pcie_suspend_noirq(struct device *dev)
@@ -443,7 +441,7 @@ static const struct of_device_id of_intel_pcie_match[] = {
443441

444442
static struct platform_driver intel_pcie_driver = {
445443
.probe = intel_pcie_probe,
446-
.remove = intel_pcie_remove,
444+
.remove_new = intel_pcie_remove,
447445
.driver = {
448446
.name = "intel-gw-pcie",
449447
.of_match_table = of_intel_pcie_match,

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ static int qcom_pcie_ep_probe(struct platform_device *pdev)
784784
return ret;
785785
}
786786

787-
static int qcom_pcie_ep_remove(struct platform_device *pdev)
787+
static void qcom_pcie_ep_remove(struct platform_device *pdev)
788788
{
789789
struct qcom_pcie_ep *pcie_ep = platform_get_drvdata(pdev);
790790

@@ -794,11 +794,9 @@ static int qcom_pcie_ep_remove(struct platform_device *pdev)
794794
debugfs_remove_recursive(pcie_ep->debugfs);
795795

796796
if (pcie_ep->link_status == QCOM_PCIE_EP_LINK_DISABLED)
797-
return 0;
797+
return;
798798

799799
qcom_pcie_disable_resources(pcie_ep);
800-
801-
return 0;
802800
}
803801

804802
static const struct of_device_id qcom_pcie_ep_match[] = {
@@ -810,7 +808,7 @@ MODULE_DEVICE_TABLE(of, qcom_pcie_ep_match);
810808

811809
static struct platform_driver qcom_pcie_ep_driver = {
812810
.probe = qcom_pcie_ep_probe,
813-
.remove = qcom_pcie_ep_remove,
811+
.remove_new = qcom_pcie_ep_remove,
814812
.driver = {
815813
.name = "qcom-pcie-ep",
816814
.of_match_table = qcom_pcie_ep_match,

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,13 +2268,13 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)
22682268
return ret;
22692269
}
22702270

2271-
static int tegra_pcie_dw_remove(struct platform_device *pdev)
2271+
static void tegra_pcie_dw_remove(struct platform_device *pdev)
22722272
{
22732273
struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev);
22742274

22752275
if (pcie->of_data->mode == DW_PCIE_RC_TYPE) {
22762276
if (!pcie->link_state)
2277-
return 0;
2277+
return;
22782278

22792279
debugfs_remove_recursive(pcie->debugfs);
22802280
tegra_pcie_deinit_controller(pcie);
@@ -2288,8 +2288,6 @@ static int tegra_pcie_dw_remove(struct platform_device *pdev)
22882288
tegra_bpmp_put(pcie->bpmp);
22892289
if (pcie->pex_refclk_sel_gpiod)
22902290
gpiod_set_value(pcie->pex_refclk_sel_gpiod, 0);
2291-
2292-
return 0;
22932291
}
22942292

22952293
static int tegra_pcie_dw_suspend_late(struct device *dev)
@@ -2483,7 +2481,7 @@ static const struct dev_pm_ops tegra_pcie_dw_pm_ops = {
24832481

24842482
static struct platform_driver tegra_pcie_dw_driver = {
24852483
.probe = tegra_pcie_dw_probe,
2486-
.remove = tegra_pcie_dw_remove,
2484+
.remove_new = tegra_pcie_dw_remove,
24872485
.shutdown = tegra_pcie_dw_shutdown,
24882486
.driver = {
24892487
.name = "tegra194-pcie",

0 commit comments

Comments
 (0)