The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Wu Bo <bo.wu@vivo.com>
To: linux-kernel@vger.kernel.org
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	"Wu Bo" <wubo.oduw@gmail.com>, "Wu Bo" <bo.wu@vivo.com>
Subject: [PATCH v3] PCI: armada8k: change to use devm_clk_get_enabled() helper
Date: Mon, 26 Aug 2024 20:39:14 -0600	[thread overview]
Message-ID: <20240827023914.2255103-1-bo.wu@vivo.com> (raw)

Use devm_clk_get_enabled() instead of devm_clk_get() to make the code
cleaner and avoid calling clk_disable_unprepare()

Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
 drivers/pci/controller/dwc/pcie-armada8k.c | 36 ++++++++--------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-armada8k.c b/drivers/pci/controller/dwc/pcie-armada8k.c
index b5c599ccaacf..e7ef6c2641b8 100644
--- a/drivers/pci/controller/dwc/pcie-armada8k.c
+++ b/drivers/pci/controller/dwc/pcie-armada8k.c
@@ -284,23 +284,17 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
 
 	pcie->pci = pci;
 
-	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);
-
-	ret = clk_prepare_enable(pcie->clk);
-	if (ret)
-		return ret;
-
-	pcie->clk_reg = devm_clk_get(dev, "reg");
-	if (pcie->clk_reg == ERR_PTR(-EPROBE_DEFER)) {
-		ret = -EPROBE_DEFER;
-		goto fail;
-	}
-	if (!IS_ERR(pcie->clk_reg)) {
-		ret = clk_prepare_enable(pcie->clk_reg);
-		if (ret)
-			goto fail_clkreg;
+		return dev_err_probe(dev, PTR_ERR(pcie->clk),
+				"could not enable clk\n");
+
+	pcie->clk_reg = devm_clk_get_enabled(dev, "reg");
+	if (IS_ERR(pcie->clk_reg)) {
+		ret = dev_err_probe(dev, PTR_ERR(pcie->clk_reg),
+				"could not enable reg clk\n");
+		if (ret == -EPROBE_DEFER)
+			goto out;
 	}
 
 	/* Get the dw-pcie unit configuration/control registers base. */
@@ -308,12 +302,12 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
 	pci->dbi_base = devm_pci_remap_cfg_resource(dev, base);
 	if (IS_ERR(pci->dbi_base)) {
 		ret = PTR_ERR(pci->dbi_base);
-		goto fail_clkreg;
+		goto out;
 	}
 
 	ret = armada8k_pcie_setup_phys(pcie);
 	if (ret)
-		goto fail_clkreg;
+		goto out;
 
 	platform_set_drvdata(pdev, pcie);
 
@@ -325,11 +319,7 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
 
 disable_phy:
 	armada8k_pcie_disable_phys(pcie);
-fail_clkreg:
-	clk_disable_unprepare(pcie->clk_reg);
-fail:
-	clk_disable_unprepare(pcie->clk);
-
+out:
 	return ret;
 }
 
-- 
2.25.1


             reply	other threads:[~2024-08-27  2:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  2:39 Wu Bo [this message]
2024-08-27  6:44 ` [PATCH v3] PCI: armada8k: change to use devm_clk_get_enabled() helper Anand Moon
2024-08-31  0:06   ` Wu Bo
2024-08-31  3:37     ` Anand Moon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240827023914.2255103-1-bo.wu@vivo.com \
    --to=bo.wu@vivo.com \
    --cc=bhelgaas@google.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wubo.oduw@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox