From: Junzhong Pan <panjunzhong@linux.spacemit.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Yixun Lan <dlan@kernel.org>,
Xu Yang <xu.yang_2@nxp.com>, Peng Fan <peng.fan@nxp.com>,
Peter Chen <peter.chen@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
spacemit@lists.linux.dev,
Junzhong Pan <panjunzhong@linux.spacemit.com>,
Ze Huang <huang.ze@linux.dev>
Subject: [PATCH v3 2/8] usb: chipidea: usb2: use devm_clk_get_optional_enabled()
Date: Sun, 27 Sep 2026 19:40:04 +0800 [thread overview]
Message-ID: <20260927-b4-spacemit-k1-usb2-v3-2-ce7095896039@linux.spacemit.com> (raw)
In-Reply-To: <20260927-b4-spacemit-k1-usb2-v3-0-ce7095896039@linux.spacemit.com>
Convert devm_clk_get_optional() and clk_prepare_enable() into a single
call devm_clk_get_optional_enabled().
Tested-by: Ze Huang <huang.ze@linux.dev>
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
drivers/usb/chipidea/ci_hdrc_usb2.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 8ffa1e95d8e8..9cef902f36b3 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -20,7 +20,6 @@
struct ci_hdrc_usb2_priv {
struct platform_device *ci_pdev;
- struct clk *clk;
};
static const struct ci_hdrc_platform_data ci_default_pdata = {
@@ -52,6 +51,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
struct ci_hdrc_usb2_priv *priv;
struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
const struct ci_hdrc_platform_data *data;
+ struct clk *clk;
int ret;
if (!ci_pdata) {
@@ -70,15 +70,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
- priv->clk = devm_clk_get_optional(dev, NULL);
- if (IS_ERR(priv->clk))
- return PTR_ERR(priv->clk);
-
- ret = clk_prepare_enable(priv->clk);
- if (ret) {
- dev_err(dev, "failed to enable the clock: %d\n", ret);
- return ret;
- }
+ clk = devm_clk_get_optional_enabled(dev, NULL);
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "failed to get or enable the clock\n");
ci_pdata->name = dev_name(dev);
@@ -90,7 +85,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
dev_err(dev,
"failed to register ci_hdrc platform device: %d\n",
ret);
- goto clk_err;
+ return ret;
}
platform_set_drvdata(pdev, priv);
@@ -99,10 +94,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
return 0;
-
-clk_err:
- clk_disable_unprepare(priv->clk);
- return ret;
}
static void ci_hdrc_usb2_remove(struct platform_device *pdev)
@@ -111,7 +102,6 @@ static void ci_hdrc_usb2_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
ci_hdrc_remove_device(priv->ci_pdev);
- clk_disable_unprepare(priv->clk);
}
static struct platform_driver ci_hdrc_usb2_driver = {
--
2.34.1
next prev parent reply other threads:[~2026-09-27 11:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 11:40 [PATCH v3 0/8] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 1/8] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible Junzhong Pan
2026-10-06 15:09 ` Krzysztof Kozlowski
2026-09-27 11:40 ` Junzhong Pan [this message]
2026-09-27 11:40 ` [PATCH v3 3/8] usb: chipidea: usb2: add optional reset support Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 4/8] usb: chipidea: usb2: add SpacemiT K1 support Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 5/8] riscv: dts: spacemit: add USB2.0 controller nodes for K1 Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 6/8] riscv: dts: spacemit: enable USB2.0 controllers on BananaPi F3 Junzhong Pan
2026-09-27 11:49 ` sashiko-bot
2026-09-28 1:50 ` Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 7/8] riscv: dts: spacemit: enable USB2.0 controllers on OrangePi RV2 Junzhong Pan
2026-09-27 11:40 ` [PATCH v3 8/8] riscv: defconfig: enable ChipIdea USB controller support Junzhong Pan
2026-09-28 22:58 ` [PATCH v3 0/8] Add SpacemiT K1 USB2.0 controllers support Yixun Lan
2026-09-28 23:03 ` Yixun Lan
2026-10-06 15:10 ` Krzysztof Kozlowski
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=20260927-b4-spacemit-k1-usb2-v3-2-ce7095896039@linux.spacemit.com \
--to=panjunzhong@linux.spacemit.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ze@linux.dev \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=palmer@dabbelt.com \
--cc=peng.fan@nxp.com \
--cc=peter.chen@kernel.org \
--cc=pjw@kernel.org \
--cc=robh@kernel.org \
--cc=spacemit@lists.linux.dev \
--cc=xu.yang_2@nxp.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