mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Huan Yang <link@vivo.com>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH] nvmem: jz4780-efuse: Use devm_clk_get_enabled() helpers
Date: Tue, 20 Aug 2024 15:21:40 +0200	[thread overview]
Message-ID: <7b31732e-00ca-4792-a16b-156689862c5b@wanadoo.fr> (raw)
In-Reply-To: <20240820102333.133503-1-link@vivo.com>

Le 20/08/2024 à 12:23, Huan Yang a écrit :
> The devm_clk_get_enabled() helpers:
>      - call devm_clk_get()
>      - call clk_prepare_enable() and register what is needed in order to
>       call clk_disable_unprepare() when needed, as a managed resource.
> 
> This simplifies the code and avoids the calls to clk_disable_unprepare().
> 
> Signed-off-by: Huan Yang <link@vivo.com>
> ---

Hi,

if you want to go 1 step further, I think that 'clk' can now also be 
removed from struct jz4780_efuse.

Just my 2c.

CJ

>   drivers/nvmem/jz4780-efuse.c | 18 +-----------------
>   1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/drivers/nvmem/jz4780-efuse.c b/drivers/nvmem/jz4780-efuse.c
> index 0b01b840edd9..2b5badfbf22f 100644
> --- a/drivers/nvmem/jz4780-efuse.c
> +++ b/drivers/nvmem/jz4780-efuse.c
> @@ -131,11 +131,6 @@ static const struct regmap_config jz4780_efuse_regmap_config = {
>   	.max_register = JZ_EFUDATA(7),
>   };
>   
> -static void clk_disable_unprepare_helper(void *clock)
> -{
> -	clk_disable_unprepare(clock);
> -}
> -
>   static int jz4780_efuse_probe(struct platform_device *pdev)
>   {
>   	struct nvmem_device *nvmem;
> @@ -146,7 +141,6 @@ static int jz4780_efuse_probe(struct platform_device *pdev)
>   	unsigned long rd_strobe;
>   	struct device *dev = &pdev->dev;
>   	void __iomem *regs;
> -	int ret;
>   
>   	efuse = devm_kzalloc(dev, sizeof(*efuse), GFP_KERNEL);
>   	if (!efuse)
> @@ -161,20 +155,10 @@ static int jz4780_efuse_probe(struct platform_device *pdev)
>   	if (IS_ERR(efuse->map))
>   		return PTR_ERR(efuse->map);
>   
> -	efuse->clk = devm_clk_get(&pdev->dev, NULL);
> +	efuse->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>   	if (IS_ERR(efuse->clk))
>   		return PTR_ERR(efuse->clk);
>   
> -	ret = clk_prepare_enable(efuse->clk);
> -	if (ret < 0)
> -		return ret;
> -
> -	ret = devm_add_action_or_reset(&pdev->dev,
> -				       clk_disable_unprepare_helper,
> -				       efuse->clk);
> -	if (ret < 0)
> -		return ret;
> -
>   	clk_rate = clk_get_rate(efuse->clk);
>   
>   	efuse->dev = dev;


  reply	other threads:[~2024-08-20 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 10:23 Huan Yang
2024-08-20 13:21 ` Christophe JAILLET [this message]
2024-08-21  1:15   ` Huan Yang

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=7b31732e-00ca-4792-a16b-156689862c5b@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=link@vivo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=srinivas.kandagatla@linaro.org \
    /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®