From: Huan Yang <link@vivo.com>
To: Russell King <linux@armlinux.org.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Huan Yang <link@vivo.com>, Randy Dunlap <rdunlap@infradead.org>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: [PATCH] ARM: sa1100: Use devm_clk_get_enabled() helpers
Date: Tue, 20 Aug 2024 17:41:18 +0800 [thread overview]
Message-ID: <20240820094121.98231-1-link@vivo.com> (raw)
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 --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
reply other threads:[~2024-08-20 9:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240820094121.98231-1-link@vivo.com \
--to=link@vivo.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=opensource.kernel@vivo.com \
--cc=rdunlap@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®