Skip to content

Commit 6fad11c

Browse files
moonlinuxbjorn-helgaas
authored andcommitted
PCI: j721e: Use devm_clk_get_optional_enabled() to get and enable the clock
Use devm_clk_get_optional_enabled() helper instead of calling devm_clk_get_optional() and then clk_prepare_enable(). Assign the result of devm_clk_get_optional_enabled() directly to pcie->refclk to avoid using a local 'clk' variable. Signed-off-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com> Link: https://patch.msgid.link/20251028154229.6774-2-linux.amoon@gmail.com
1 parent 3a86608 commit 6fad11c

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ static int j721e_pcie_probe(struct platform_device *pdev)
479479
struct cdns_pcie_ep *ep = NULL;
480480
struct gpio_desc *gpiod;
481481
void __iomem *base;
482-
struct clk *clk;
483482
u32 num_lanes;
484483
u32 mode;
485484
int ret;
@@ -603,19 +602,13 @@ static int j721e_pcie_probe(struct platform_device *pdev)
603602
goto err_get_sync;
604603
}
605604

606-
clk = devm_clk_get_optional(dev, "pcie_refclk");
607-
if (IS_ERR(clk)) {
608-
ret = dev_err_probe(dev, PTR_ERR(clk), "failed to get pcie_refclk\n");
605+
pcie->refclk = devm_clk_get_optional_enabled(dev, "pcie_refclk");
606+
if (IS_ERR(pcie->refclk)) {
607+
ret = dev_err_probe(dev, PTR_ERR(pcie->refclk),
608+
"failed to enable pcie_refclk\n");
609609
goto err_pcie_setup;
610610
}
611611

612-
ret = clk_prepare_enable(clk);
613-
if (ret) {
614-
dev_err_probe(dev, ret, "failed to enable pcie_refclk\n");
615-
goto err_pcie_setup;
616-
}
617-
pcie->refclk = clk;
618-
619612
/*
620613
* Section 2.2 of the PCI Express Card Electromechanical
621614
* Specification (Revision 5.1) mandates that the deassertion
@@ -629,10 +622,8 @@ static int j721e_pcie_probe(struct platform_device *pdev)
629622
}
630623

631624
ret = cdns_pcie_host_setup(rc);
632-
if (ret < 0) {
633-
clk_disable_unprepare(pcie->refclk);
625+
if (ret < 0)
634626
goto err_pcie_setup;
635-
}
636627

637628
break;
638629
case PCI_MODE_EP:
@@ -679,7 +670,6 @@ static void j721e_pcie_remove(struct platform_device *pdev)
679670

680671
gpiod_set_value_cansleep(pcie->reset_gpio, 0);
681672

682-
clk_disable_unprepare(pcie->refclk);
683673
cdns_pcie_disable_phy(cdns_pcie);
684674
j721e_pcie_disable_link_irq(pcie);
685675
pm_runtime_put(dev);

0 commit comments

Comments
 (0)