[PATCH] hwspinlock: sprd: Use devm_clk_get_enabled() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux