Linux Remote Processor Subsystem development
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Orson Zhai <orsonzhai@gmail.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper
Date: Thu, 25 Aug 2022 08:54:35 +0800	[thread overview]
Message-ID: <472ee15f-b89a-dc5a-548d-f2374f99dda0@linux.alibaba.com> (raw)
In-Reply-To: <f962d22bfdbd09133d8923152133eeff9213dcee.1661324434.git.christophe.jaillet@wanadoo.fr>



On 8/24/2022 3:55 PM, Christophe JAILLET wrote:
> The devm_clk_get_enabled() helper:
>     - calls devm_clk_get()
>     - calls clk_prepare_enable() and registers what is needed in order to
>       call clk_disable_unprepare() when needed, as a managed resource.
> 
> This simplifies the code, the error handling paths and avoid the need of
> a dedicated function used with devm_add_action_or_reset().
> 
> Based on my test with allyesconfig, this reduces the .o size from:
>     text	   data	    bss	    dec	    hex	filename
>     3423	   1528	      0	   4951	   1357	drivers/hwspinlock/sprd_hwspinlock.o
> down to:
>     3025	   1392	      0	   4417	   1141	drivers/hwspinlock/sprd_hwspinlock.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

> ---
> devm_clk_get_enabled() is new and is part of 6.0-rc1
> ---
>   drivers/hwspinlock/sprd_hwspinlock.c | 23 ++---------------------
>   1 file changed, 2 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd_hwspinlock.c
> index 22e2ffb91743..cb37706f61be 100644
> --- a/drivers/hwspinlock/sprd_hwspinlock.c
> +++ b/drivers/hwspinlock/sprd_hwspinlock.c
> @@ -76,18 +76,11 @@ static const struct hwspinlock_ops sprd_hwspinlock_ops = {
>   	.relax = sprd_hwspinlock_relax,
>   };
>   
> -static void sprd_hwspinlock_disable(void *data)
> -{
> -	struct sprd_hwspinlock_dev *sprd_hwlock = data;
> -
> -	clk_disable_unprepare(sprd_hwlock->clk);
> -}
> -
>   static int sprd_hwspinlock_probe(struct platform_device *pdev)
>   {
>   	struct sprd_hwspinlock_dev *sprd_hwlock;
>   	struct hwspinlock *lock;
> -	int i, ret;
> +	int i;
>   
>   	if (!pdev->dev.of_node)
>   		return -ENODEV;
> @@ -102,24 +95,12 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev)
>   	if (IS_ERR(sprd_hwlock->base))
>   		return PTR_ERR(sprd_hwlock->base);
>   
> -	sprd_hwlock->clk = devm_clk_get(&pdev->dev, "enable");
> +	sprd_hwlock->clk = devm_clk_get_enabled(&pdev->dev, "enable");
>   	if (IS_ERR(sprd_hwlock->clk)) {
>   		dev_err(&pdev->dev, "get hwspinlock clock failed!\n");
>   		return PTR_ERR(sprd_hwlock->clk);
>   	}
>   
> -	ret = clk_prepare_enable(sprd_hwlock->clk);
> -	if (ret)
> -		return ret;
> -
> -	ret = devm_add_action_or_reset(&pdev->dev, sprd_hwspinlock_disable,
> -				       sprd_hwlock);
> -	if (ret) {
> -		dev_err(&pdev->dev,
> -			"Failed to add hwspinlock disable action\n");
> -		return ret;
> -	}
> -
>   	/* set the hwspinlock to record user id to identify subsystems */
>   	writel(HWSPINLOCK_USER_BITS, sprd_hwlock->base + HWSPINLOCK_RECCTRL);
>   

      reply	other threads:[~2022-08-25  0:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24  7:55 [PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper Christophe JAILLET
2022-08-25  0:54 ` Baolin Wang [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=472ee15f-b89a-dc5a-548d-f2374f99dda0@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=orsonzhai@gmail.com \
    --cc=zhang.lyra@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