From: Mingwei Zheng <zmw12306@gmail.com>
To: linus.walleij@linaro.org, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, make24@iscas.ac.cn,
peng.fan@nxp.com, fabien.dessenne@foss.st.com, marex@denx.de
Cc: linux-gpio@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Mingwei Zheng <zmw12306@gmail.com>,
Jiasheng Jiang <jiashengjiangcool@gmail.com>
Subject: [PATCH] pinctrl: stm32: Add check for clk_enable()
Date: Wed, 4 Dec 2024 23:59:42 -0500 [thread overview]
Message-ID: <20241205045942.2441430-1-zmw12306@gmail.com> (raw)
Add check for the return value of clk_enable() to catch the potential
error. Add a cleanup loop to disable clocks already enabled in case
of an error during clock enabling for subsequent banks.
Fixes: 05d8af449d93 ("pinctrl: stm32: Keep pinctrl block clock enabled when LEVEL IRQ requested")
Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
drivers/pinctrl/stm32/pinctrl-stm32.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 5b7fa77c1184..eb7b2f864d88 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1738,10 +1738,16 @@ int __maybe_unused stm32_pinctrl_resume(struct device *dev)
{
struct stm32_pinctrl *pctl = dev_get_drvdata(dev);
struct stm32_pinctrl_group *g = pctl->groups;
- int i;
+ int i, j, ret;
- for (i = 0; i < pctl->nbanks; i++)
- clk_enable(pctl->banks[i].clk);
+ for (i = 0; i < pctl->nbanks; i++) {
+ ret = clk_enable(pctl->banks[i].clk);
+ if (ret) {
+ for (j = 0; j < i; j++)
+ clk_disable(pctl->banks[j].clk);
+ return ret;
+ }
+ }
for (i = 0; i < pctl->ngroups; i++, g++)
stm32_pinctrl_restore_gpio_regs(pctl, g->pin);
--
2.34.1
next reply other threads:[~2024-12-05 4:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 4:59 Mingwei Zheng [this message]
2024-12-05 5:07 ` [PATCH] pinctrl: stm32: Add check for clk_enable() Marek Vasut
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=20241205045942.2441430-1-zmw12306@gmail.com \
--to=zmw12306@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=fabien.dessenne@foss.st.com \
--cc=jiashengjiangcool@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=make24@iscas.ac.cn \
--cc=marex@denx.de \
--cc=mcoquelin.stm32@gmail.com \
--cc=peng.fan@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