lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <f962d22bfdbd09133d8923152133eeff9213dcee.1661324434.git.christophe.jaillet@wanadoo.fr>
Date:   Wed, 24 Aug 2022 09:55:47 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Ohad Ben-Cohen <ohad@...ery.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        Orson Zhai <orsonzhai@...il.com>,
        Chunyan Zhang <zhang.lyra@...il.com>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        linux-remoteproc@...r.kernel.org
Subject: [PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper

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>
---
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);
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ