From patchwork Wed Aug 24 07:55:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12953024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D0D0C32792 for ; Wed, 24 Aug 2022 08:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235048AbiHXID1 (ORCPT ); Wed, 24 Aug 2022 04:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234769AbiHXIDY (ORCPT ); Wed, 24 Aug 2022 04:03:24 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE345861E8 for ; Wed, 24 Aug 2022 01:03:23 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id QlEroa3jzPMmaQlEropAN6; Wed, 24 Aug 2022 09:55:50 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 24 Aug 2022 09:55:50 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Ohad Ben-Cohen , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-remoteproc@vger.kernel.org Subject: [PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper Date: Wed, 24 Aug 2022 09:55:47 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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 Reviewed-by: Baolin Wang --- 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);