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>] [day] [month] [year] [list]
Message-ID: <20240820094121.98231-1-link@vivo.com>
Date: Tue, 20 Aug 2024 17:41:18 +0800
From: Huan Yang <link@...o.com>
To: Russell King <linux@...linux.org.uk>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Huan Yang <link@...o.com>,
	Randy Dunlap <rdunlap@...radead.org>,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: [PATCH] ARM: sa1100: Use devm_clk_get_enabled() helpers

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@...o.com>
---
 arch/arm/common/sa1111.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

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
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ