Skip to contentSkip to conversation

PCI: xilinx-nwl: Use devm_clk_get_enabled() in nwl_pcie_probe()

PATCH In review Markus Elfring 4 participants 5 messages Nov 22 – Nov 25

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: xilinx-nwl: Use devm_clk_get_enabled() in nwl_pcie_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 22 Nov 2026 20:35:35 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code.

* Omit a clk_disable_unprepare() call on an error handling path and in the implementation of the function “nwl_pcie_remove”.

* Delete the label “err_clk”.

This issue was detected by using the Coccinelle software.

---
 drivers/pci/controller/pcie-xilinx-nwl.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +2 -11
index 0dee19fa24ca..fd134317e9c4 100644
@@ -844,20 +844,14 @@ static int nwl_pcie_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	pcie->clk = devm_clk_get(dev, NULL);
+	pcie->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(pcie->clk))
 		return PTR_ERR(pcie->clk);
 
-	err = clk_prepare_enable(pcie->clk);
-	if (err) {
-		dev_err(dev, "can't enable PCIe ref clock\n");
-		return err;
-	}
-
 	err = nwl_pcie_phy_enable(pcie);
 	if (err) {
 		dev_err(dev, "could not enable PHYs\n");
-		goto err_clk;
+		return err;
 	}
 
 	err = nwl_pcie_bridge_init(pcie);
@@ -889,8 +883,6 @@ static int nwl_pcie_probe(struct platform_device *pdev)
 
 err_phy:
 	nwl_pcie_phy_disable(pcie);
-err_clk:
-	clk_disable_unprepare(pcie->clk);
 	return err;
 }
 
@@ -899,7 +891,6 @@ static void nwl_pcie_remove(struct platform_device *pdev)
 	struct nwl_pcie *pcie = platform_get_drvdata(pdev);
 
 	nwl_pcie_phy_disable(pcie);
-	clk_disable_unprepare(pcie->clk);
 }
 
 static struct platform_driver nwl_pcie_driver = {
Signature · 1 line
2.56.1
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

From: Markus Elfring <[email protected]>
Date: Sun, 22 Nov 2026 20:35:35 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code.

Quoted 8 lines

* Omit a clk_disable_unprepare() call on an error handling path and in the implementation of the function “nwl_pcie_remove”.

* Delete the label “err_clk”.

This issue was detected by using the Coccinelle software.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Markus Elfring
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 22 Nov 2026 20:35:35 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code.

* Omit a clk_disable_unprepare() call on an error handling path and in the implementation of the function “nwl_pcie_remove”.

* Delete the label “err_clk”.

Needn't * in this case. Not title ahead of a list at body.

Frank

Quoted 55 lines

This issue was detected by using the Coccinelle software.

---
 drivers/pci/controller/pcie-xilinx-nwl.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +2 -12
index 0dee19fa24ca..fd134317e9c4 100644
@@ -844,20 +844,14 @@ static int nwl_pcie_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	pcie->clk = devm_clk_get(dev, NULL);
+	pcie->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(pcie->clk))
 		return PTR_ERR(pcie->clk);
 
-	err = clk_prepare_enable(pcie->clk);
-	if (err) {
-		dev_err(dev, "can't enable PCIe ref clock\n");
-		return err;
-	}
-
 	err = nwl_pcie_phy_enable(pcie);
 	if (err) {
 		dev_err(dev, "could not enable PHYs\n");
-		goto err_clk;
+		return err;
 	}
 
 	err = nwl_pcie_bridge_init(pcie);
@@ -889,8 +883,6 @@ static int nwl_pcie_probe(struct platform_device *pdev)
 
 err_phy:
 	nwl_pcie_phy_disable(pcie);
-err_clk:
-	clk_disable_unprepare(pcie->clk);
 	return err;
 }
 
@@ -899,7 +891,6 @@ static void nwl_pcie_remove(struct platform_device *pdev)
 	struct nwl_pcie *pcie = platform_get_drvdata(pdev);
 
 	nwl_pcie_phy_disable(pcie);
-	clk_disable_unprepare(pcie->clk);
 }
 
 static struct platform_driver nwl_pcie_driver = {
--

2.56.1

#3 lore raw
Quoted 9 lines
Quoted 7 lines

* Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code.

* Omit a clk_disable_unprepare() call on an error handling path and in the implementation of the function “nwl_pcie_remove”.

* Delete the label “err_clk”.

Needn't * in this case. Not title ahead of a list at body.

Which wording variation would you prefer finally?

Regards,
Markus

#4 lore raw
In reply to Markus Elfring
Quoted 11 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 22 Nov 2026 20:35:35 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of keeping duplicate source code.

* Omit a clk_disable_unprepare() call on an error handling path and in the implementation of the function “nwl_pcie_remove”.

* Delete the label “err_clk”.

THis isn't how the commit message should be written. It should be contiguous, not bullet points and just say what the patches does and why it is needed.

- Mani