diff mbox series

ARM: sa1100: Use devm_clk_get_enabled() helpers

Message ID 20240820094121.98231-1-link@vivo.com (mailing list archive)
State New, archived
Headers show
Series ARM: sa1100: Use devm_clk_get_enabled() helpers | expand

Commit Message

Huan Yang Aug. 20, 2024, 9:41 a.m. UTC
Current clk prepare, enable, disable, unprepare is split, this patch use
of simplifies helper devm_clk_getn_enabled, which can avoids the calls
to disable unprepare when remove. move enable from wake to keep it simple

Signed-off-by: Huan Yang <link@vivo.com>
---
 arch/arm/common/sa1111.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 550978dc3c50..10849ea04071 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -642,8 +642,6 @@  static void sa1111_wake(struct sa1111 *sachip)
 
 	spin_lock_irqsave(&sachip->lock, flags);
 
-	clk_enable(sachip->clk);
-
 	/*
 	 * Turn VCO on, and disable PLL Bypass.
 	 */
@@ -800,14 +798,6 @@  static int __sa1111_probe(struct device *me, struct resource *mem, int irq)
 	if (!sachip)
 		return -ENOMEM;
 
-	sachip->clk = devm_clk_get(me, "SA1111_CLK");
-	if (IS_ERR(sachip->clk))
-		return PTR_ERR(sachip->clk);
-
-	ret = clk_prepare(sachip->clk);
-	if (ret)
-		return ret;
-
 	spin_lock_init(&sachip->lock);
 
 	sachip->dev = me;
@@ -822,10 +812,8 @@  static int __sa1111_probe(struct device *me, struct resource *mem, int irq)
 	 * registers for our children.
 	 */
 	sachip->base = ioremap(mem->start, PAGE_SIZE * 2);
-	if (!sachip->base) {
-		ret = -ENOMEM;
-		goto err_clk_unprep;
-	}
+	if (!sachip->base)
+		return -ENOMEM;
 
 	/*
 	 * Probe for the chip.  Only touch the SBI registers.
@@ -843,6 +831,12 @@  static int __sa1111_probe(struct device *me, struct resource *mem, int irq)
 	/*
 	 * We found it.  Wake the chip up, and initialise.
 	 */
+	sachip->clk = devm_clk_get_enabled(me, "SA1111_CLK");
+	if (IS_ERR(sachip->clk)) {
+		ret = PTR_ERR(sachip->clk);
+		goto err_unmap;
+	}
+
 	sa1111_wake(sachip);
 
 	/*
@@ -851,7 +845,7 @@  static int __sa1111_probe(struct device *me, struct resource *mem, int irq)
 	 */
 	ret = sa1111_setup_irq(sachip, pd->irq_base);
 	if (ret)
-		goto err_clk;
+		goto err_unmap;
 
 	/* Setup the GPIOs - should really be done after the IRQ setup */
 	ret = sa1111_setup_gpios(sachip);
@@ -902,12 +896,8 @@  static int __sa1111_probe(struct device *me, struct resource *mem, int irq)
 
  err_irq:
 	sa1111_remove_irq(sachip);
- err_clk:
-	clk_disable(sachip->clk);
  err_unmap:
 	iounmap(sachip->base);
- err_clk_unprep:
-	clk_unprepare(sachip->clk);
 	return ret;
 }
 
@@ -928,9 +918,6 @@  static void __sa1111_remove(struct sa1111 *sachip)
 
 	sa1111_remove_irq(sachip);
 
-	clk_disable(sachip->clk);
-	clk_unprepare(sachip->clk);
-
 	iounmap(sachip->base);
 }
 
@@ -1048,6 +1035,8 @@  static int sa1111_resume_noirq(struct device *dev)
 	/*
 	 * First of all, wake up the chip.
 	 */
+	clk_enable(sachip->clk);
+
 	sa1111_wake(sachip);
 
 #ifdef CONFIG_ARCH_SA1100