From: Marek Vasut <marex@denx.de>
To: Mingwei Zheng <zmw12306@gmail.com>
Cc: antonio.borneo@foss.st.com, 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, linux-gpio@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Jiasheng Jiang <jiashengjiangcool@gmail.com>
Subject: Re: [PATCH RESEND v7] pinctrl: stm32: Add check for clk_enable()
Date: Sun, 29 Dec 2024 18:11:43 +0100 [thread overview]
Message-ID: <b2f2f1e6-a539-4d1b-876f-6715c126ac3e@denx.de> (raw)
In-Reply-To: <20241224200608.84923-1-zmw12306@gmail.com>
On 12/24/24 9:06 PM, Mingwei Zheng wrote:
[...]
> @@ -1390,15 +1379,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
> err = gpiochip_add_data(&bank->gpio_chip, bank);
There is one other nasty problem here -- this gpiochip_add_data() needs
to be undone (*) below, otherwise ...
...
> + ret = clk_bulk_prepare_enable(banks, pctl->clks);
> + if (ret) {
> + dev_err(dev, "failed to prepare_enable clk (%d)\n", ret);
> + return ret;
> + }
> +
> for_each_gpiochip_node(dev, child) {
> ret = stm32_gpiolib_register_bank(pctl, child);
... if this stm32_gpiolib_register_bank() fails for second or later bank
, then ...
> if (ret) {
> fwnode_handle_put(child);
> -
> - for (i = 0; i < pctl->nbanks; i++)
> - clk_disable_unprepare(pctl->banks[i].clk);
> -
> - return ret;
> + goto err_clk;
> }
>
> pctl->nbanks++;
> @@ -1658,6 +1642,10 @@ int stm32_pctl_probe(struct platform_device *pdev)
> dev_info(dev, "Pinctrl STM32 initialized\n");
>
> return 0;
> +
> +err_clk:
> + clk_bulk_disable_unprepare(banks, pctl->clks);
... this clk_bulk_disable_unprepare() will disable all bank clocks,
including the clocks for the banks which got successfully registered.
Before calling clk_bulk_disable_unprepare(), it is necessary to
unregister the GPIO chips again, i.e.:
i = 0;
for_each_gpiochip_node(dev, child) {
struct stm32_gpio_bank *bank = &pctl->banks[i];
gpiochip_remove(*bank->gpio_chip);
}
clk_bulk_disable_unprepare(banks, pctl->clks);
Otherwise I think the patch is pretty good, thank you !
prev parent reply other threads:[~2024-12-29 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 20:06 Mingwei Zheng
2024-12-29 17:11 ` Marek Vasut [this message]
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=b2f2f1e6-a539-4d1b-876f-6715c126ac3e@denx.de \
--to=marex@denx.de \
--cc=alexandre.torgue@foss.st.com \
--cc=antonio.borneo@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=mcoquelin.stm32@gmail.com \
--cc=peng.fan@nxp.com \
--cc=zmw12306@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
all inboxes | Powered by JetHome®