Skip to contentSkip to conversation

PCI: fu740: Check return value of clk_prepare_enable()

PATCH New Jayaraj Devaraj 2 participants 2 messages Dec 1

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

PATCH v2 1/1 PCI: fu740: Check return value of clk_prepare_enable()

fu740_pcie_host_init() ignores the return value of the second clk_prepare_enable() call on pcie_aux, so a failure to enable the clock is silently ignored and the controller is programmed anyway.

Check the return value and propagate the error.

Fixes e7e21b3a339b ("PCI: fu740: Add SiFive FU740 PCIe host controller driver")

---
Changes in v2:
- Add Fixes: tag.
- Rebase on pci/next.

 drivers/pci/controller/dwc/pcie-fu740.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-fu740.c +5 -1
index 00ec69a09164..b2eded23b52c 100644
@@ -270,7 +270,11 @@ static int fu740_pcie_host_init(struct dw_pcie_rp *pp)
 	/* Clear hold_phy_rst */
 	writel_relaxed(0x0, afp->mgmt_base + PCIEX8MGMT_APP_HOLD_PHY_RST);
 	/* Enable pcieauxclk */
-	clk_prepare_enable(afp->pcie_aux);
+	ret = clk_prepare_enable(afp->pcie_aux);
+	if (ret) {
+		dev_err(dev, "unable to re-enable pcie_aux clock\n");
+		return ret;
+	}
 	/* Set RC mode */
 	writel_relaxed(0x4, afp->mgmt_base + PCIEX8MGMT_DEVICE_TYPE);
 
Signature · 1 line
2.34.1
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

fu740_pcie_host_init() ignores the return value of the second clk_prepare_enable() call on pcie_aux, so a failure to enable the clock is silently ignored and the controller is programmed anyway.

Check the return value and propagate the error.

Fixes e7e21b3a339b ("PCI: fu740: Add SiFive FU740 PCIe host controller driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1