[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <472ee15f-b89a-dc5a-548d-f2374f99dda0@linux.alibaba.com>
Date: Thu, 25 Aug 2022 08:54:35 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Ohad Ben-Cohen <ohad@...ery.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Orson Zhai <orsonzhai@...il.com>,
Chunyan Zhang <zhang.lyra@...il.com>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
linux-remoteproc@...r.kernel.org
Subject: Re: [PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper
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@...adoo.fr>
LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@...ux.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);
>
Powered by blists - more mailing lists