mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Clement LE GOFFIC <clement.legoffic@foss.st.com>
To: Mingwei Zheng <zmw12306@gmail.com>, <marex@denx.de>,
	<antonio.borneo@foss.st.com>
Cc: <peng.fan@nxp.com>, <make24@iscas.ac.cn>,
	<linus.walleij@linaro.org>, <linux-kernel@vger.kernel.org>,
	<linux-gpio@vger.kernel.org>,
	Jiasheng Jiang <jiashengjiangcool@gmail.com>,
	<fabien.dessenne@foss.st.com>, <mcoquelin.stm32@gmail.com>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [Linux-stm32] [PATCH v4] pinctrl: stm32: Add check for clk_enable()
Date: Fri, 13 Dec 2024 12:16:33 +0100	[thread overview]
Message-ID: <6d893831-7a2e-4a9a-a519-2e257e249f0f@foss.st.com> (raw)
In-Reply-To: <20241213010948.2623382-1-zmw12306@gmail.com>


On 12/13/24 02:09, Mingwei Zheng wrote:
> Convert the driver to clk_bulk*() API.
> Add check for the return value of clk_bulk_enable() to catch
> the potential error.
> 
> 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>
> ---
> Changelog:
> 
> v3 -> v4:
> 1. Add initialization for  pctl->clks.
> 2. Adjust alignment.
> 
> v2 -> v3:
> 
> 1. Convert clk_disable_unprepare to clk_bulk_disable
> and clk_bulk_unprepare.
> 
> v1 -> v2:
> 
> 1. Move int ret declaration into if block.
> ---
>   drivers/pinctrl/stm32/pinctrl-stm32.c | 37 +++++++++++++++------------
>   1 file changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index 5b7fa77c1184..427749d4f6a5 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -86,7 +86,6 @@ struct stm32_pinctrl_group {
>   
>   struct stm32_gpio_bank {
>   	void __iomem *base;
> -	struct clk *clk;
>   	struct reset_control *rstc;
>   	spinlock_t lock;
>   	struct gpio_chip gpio_chip;
> @@ -108,6 +107,7 @@ struct stm32_pinctrl {
>   	unsigned ngroups;
>   	const char **grp_names;
>   	struct stm32_gpio_bank *banks;
> +	struct clk_bulk_data *clks;
>   	unsigned nbanks;
>   	const struct stm32_pinctrl_match_data *match_data;
>   	struct irq_domain	*domain;
> @@ -1308,7 +1308,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
>   	if (IS_ERR(bank->base))
>   		return PTR_ERR(bank->base);
>   
> -	err = clk_prepare_enable(bank->clk);
> +	err = clk_prepare_enable(pctl->clks[pctl->nbanks].clk);
>   	if (err) {
>   		dev_err(dev, "failed to prepare_enable clk (%d)\n", err);
>   		return err;
> @@ -1397,7 +1397,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
>   	return 0;
>   
>   err_clk:
> -	clk_disable_unprepare(bank->clk);
> +	clk_disable_unprepare(pctl->clks[pctl->nbanks].clk);
>   	return err;
>   }
>   
> @@ -1617,10 +1617,18 @@ int stm32_pctl_probe(struct platform_device *pdev)
>   		return -EINVAL;
>   	}
>   	pctl->banks = devm_kcalloc(dev, banks, sizeof(*pctl->banks),
> -			GFP_KERNEL);
> +				   GFP_KERNEL);
>   	if (!pctl->banks)
>   		return -ENOMEM;
>   
> +	pctl->clks = devm_kcalloc(dev, banks, sizeof(*pctl->clks),
> +				  GFP_KERNEL);
> +	if (!pctl->clks)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < banks; ++i)
> +		pctl->clks[i].id = "";
> +
>   	i = 0;
>   	for_each_gpiochip_node(dev, child) {
>   		struct stm32_gpio_bank *bank = &pctl->banks[i];
> @@ -1631,11 +1639,10 @@ int stm32_pctl_probe(struct platform_device *pdev)
>   			fwnode_handle_put(child);
>   			return -EPROBE_DEFER;
>   		}
> -
> -		bank->clk = of_clk_get_by_name(np, NULL);
> -		if (IS_ERR(bank->clk)) {
> +		pctl->clks[i].clk = of_clk_get_by_name(np, NULL);
> +		if (IS_ERR(pctl->clks[i].clk)) {
>   			fwnode_handle_put(child);
> -			return dev_err_probe(dev, PTR_ERR(bank->clk),
> +			return dev_err_probe(dev, PTR_ERR(pctl->clks[i].clk),
>   					     "failed to get clk\n");
>   		}
>   		i++;
> @@ -1646,8 +1653,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
>   		if (ret) {
>   			fwnode_handle_put(child);
>   
> -			for (i = 0; i < pctl->nbanks; i++)
> -				clk_disable_unprepare(pctl->banks[i].clk);
> +			clk_bulk_disable_unprepare(pctl->nbanks, pctl->clks);
>   
>   			return ret;
>   		}
> @@ -1726,10 +1732,8 @@ static int __maybe_unused stm32_pinctrl_restore_gpio_regs(
>   int __maybe_unused stm32_pinctrl_suspend(struct device *dev)
>   {
>   	struct stm32_pinctrl *pctl = dev_get_drvdata(dev);
> -	int i;
>   
> -	for (i = 0; i < pctl->nbanks; i++)
> -		clk_disable(pctl->banks[i].clk);
> +	clk_bulk_disable(pctl->nbanks, pctl->clks);
>   
>   	return 0;
>   }
> @@ -1738,10 +1742,11 @@ 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, ret;
>   
> -	for (i = 0; i < pctl->nbanks; i++)
> -		clk_enable(pctl->banks[i].clk);
> +	ret = clk_bulk_enable(pctl->nbanks, pctl->clks);
> +	if (ret)
> +		return ret;
>   
>   	for (i = 0; i < pctl->ngroups; i++, g++)
>   		stm32_pinctrl_restore_gpio_regs(pctl, g->pin);


Tested-by: Clément Le Goffic <clement.legoffic@foss.st.com>

  reply	other threads:[~2024-12-13 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  1:09 Mingwei Zheng
2024-12-13 11:16 ` Clement LE GOFFIC [this message]
2024-12-13 11:24 ` Antonio Borneo
2024-12-13 11:45 ` Marek Vasut
2024-12-13 13:43   ` Antonio Borneo

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=6d893831-7a2e-4a9a-a519-2e257e249f0f@foss.st.com \
    --to=clement.legoffic@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=marex@denx.de \
    --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®