Skip to content

Commit cfd6790

Browse files
Sean Andersonbjorn-helgaas
authored andcommitted
PCI: xilinx-nwl: Clean up clock on probe failure/removal
Make sure we turn off the clock on probe failure and device removal. Fixes: de0a01f ("PCI: xilinx-nwl: Enable the clock through CCF") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Anderson <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 78457ca commit cfd6790

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/pci/controller/pcie-xilinx-nwl.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ static int nwl_pcie_probe(struct platform_device *pdev)
779779
return -ENODEV;
780780

781781
pcie = pci_host_bridge_priv(bridge);
782+
platform_set_drvdata(pdev, pcie);
782783

783784
pcie->dev = dev;
784785

@@ -801,13 +802,13 @@ static int nwl_pcie_probe(struct platform_device *pdev)
801802
err = nwl_pcie_bridge_init(pcie);
802803
if (err) {
803804
dev_err(dev, "HW Initialization failed\n");
804-
return err;
805+
goto err_clk;
805806
}
806807

807808
err = nwl_pcie_init_irq_domain(pcie);
808809
if (err) {
809810
dev_err(dev, "Failed creating IRQ Domain\n");
810-
return err;
811+
goto err_clk;
811812
}
812813

813814
bridge->sysdata = pcie;
@@ -817,11 +818,24 @@ static int nwl_pcie_probe(struct platform_device *pdev)
817818
err = nwl_pcie_enable_msi(pcie);
818819
if (err < 0) {
819820
dev_err(dev, "failed to enable MSI support: %d\n", err);
820-
return err;
821+
goto err_clk;
821822
}
822823
}
823824

824-
return pci_host_probe(bridge);
825+
err = pci_host_probe(bridge);
826+
if (!err)
827+
return 0;
828+
829+
err_clk:
830+
clk_disable_unprepare(pcie->clk);
831+
return err;
832+
}
833+
834+
static void nwl_pcie_remove(struct platform_device *pdev)
835+
{
836+
struct nwl_pcie *pcie = platform_get_drvdata(pdev);
837+
838+
clk_disable_unprepare(pcie->clk);
825839
}
826840

827841
static struct platform_driver nwl_pcie_driver = {
@@ -831,5 +845,6 @@ static struct platform_driver nwl_pcie_driver = {
831845
.of_match_table = nwl_pcie_of_match,
832846
},
833847
.probe = nwl_pcie_probe,
848+
.remove_new = nwl_pcie_remove,
834849
};
835850
builtin_platform_driver(nwl_pcie_driver);

0 commit comments

Comments
 (0)