From: Dong Aisheng <aisheng.dong@freescale.com>
To: <linux-clk@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <sboyd@codeaurora.org>,
<mturquette@linaro.org>, <shawn.guo@linaro.org>,
<b29396@freescale.com>, <linux-arm-kernel@lists.infradead.org>,
<Ranjani.Vaidyanathan@freescale.com>, <b20596@freescale.com>,
<r64343@freescale.com>, <b20788@freescale.com>
Subject: [PATCH v2 2/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions
Date: Thu, 14 May 2015 21:29:00 +0800 [thread overview]
Message-ID: <1431610143-21853-3-git-send-email-aisheng.dong@freescale.com> (raw)
In-Reply-To: <1431610143-21853-1-git-send-email-aisheng.dong@freescale.com>
This can be useful when clock core wants to enable/disable clocks.
Then we don't have to convert the struct clk_core to struct clk to call
clk_enable/clk_disable which is a bit un-align with exist using.
And after introduce clk_core_{enable|disable}_lock, we can refine
clk_eanble and clk_disable a bit.
As well as clk_core_{enable|disable}_lock, we also added
clk_core_{prepare|unprepare}_lock and clk_core_prepare_enable/
clk_core_unprepare_disable for clock core to easily use.
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Dong Aisheng <aisheng.dong@freescale.com>
---
drivers/clk/clk.c | 85 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 63 insertions(+), 22 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 0e813ea..2f44c8c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -565,6 +565,13 @@ static void clk_core_unprepare(struct clk_core *core)
clk_core_unprepare(core->parent);
}
+static void clk_core_unprepare_lock(struct clk_core *core)
+{
+ clk_prepare_lock();
+ clk_core_unprepare(core);
+ clk_prepare_unlock();
+}
+
/**
* clk_unprepare - undo preparation of a clock source
* @clk: the clk being unprepared
@@ -581,9 +588,7 @@ void clk_unprepare(struct clk *clk)
if (IS_ERR_OR_NULL(clk))
return;
- clk_prepare_lock();
- clk_core_unprepare(clk->core);
- clk_prepare_unlock();
+ clk_core_unprepare_lock(clk->core);
}
EXPORT_SYMBOL_GPL(clk_unprepare);
@@ -619,6 +624,17 @@ static int clk_core_prepare(struct clk_core *core)
return 0;
}
+static int clk_core_prepare_lock(struct clk_core *core)
+{
+ int ret;
+
+ clk_prepare_lock();
+ ret = clk_core_prepare(core);
+ clk_prepare_unlock();
+
+ return ret;
+}
+
/**
* clk_prepare - prepare a clock source
* @clk: the clk being prepared
@@ -633,16 +649,10 @@ static int clk_core_prepare(struct clk_core *core)
*/
int clk_prepare(struct clk *clk)
{
- int ret;
-
if (!clk)
return 0;
- clk_prepare_lock();
- ret = clk_core_prepare(clk->core);
- clk_prepare_unlock();
-
- return ret;
+ return clk_core_prepare_lock(clk->core);
}
EXPORT_SYMBOL_GPL(clk_prepare);
@@ -669,6 +679,15 @@ static void clk_core_disable(struct clk_core *core)
clk_core_disable(core->parent);
}
+static void clk_core_disable_lock(struct clk_core *core)
+{
+ unsigned long flags;
+
+ flags = clk_enable_lock();
+ clk_core_disable(core);
+ clk_enable_unlock(flags);
+}
+
/**
* clk_disable - gate a clock
* @clk: the clk being gated
@@ -683,14 +702,10 @@ static void clk_core_disable(struct clk_core *core)
*/
void clk_disable(struct clk *clk)
{
- unsigned long flags;
-
if (IS_ERR_OR_NULL(clk))
return;
- flags = clk_enable_lock();
- clk_core_disable(clk->core);
- clk_enable_unlock(flags);
+ clk_core_disable_lock(clk->core);
}
EXPORT_SYMBOL_GPL(clk_disable);
@@ -729,6 +744,18 @@ static int clk_core_enable(struct clk_core *core)
return 0;
}
+static int clk_core_enable_lock(struct clk_core *core)
+{
+ unsigned long flags;
+ int ret;
+
+ flags = clk_enable_lock();
+ ret = clk_core_enable(core);
+ clk_enable_unlock(flags);
+
+ return ret;
+}
+
/**
* clk_enable - ungate a clock
* @clk: the clk being ungated
@@ -744,19 +771,33 @@ static int clk_core_enable(struct clk_core *core)
*/
int clk_enable(struct clk *clk)
{
- unsigned long flags;
- int ret;
-
if (!clk)
return 0;
- flags = clk_enable_lock();
- ret = clk_core_enable(clk->core);
- clk_enable_unlock(flags);
+ return clk_core_enable_lock(clk->core);
+}
+EXPORT_SYMBOL_GPL(clk_enable);
+
+static int clk_core_prepare_enable(struct clk_core *core)
+{
+ int ret;
+
+ ret = clk_core_prepare_lock(core);
+ if (ret)
+ return ret;
+
+ ret = clk_core_enable_lock(core);
+ if (ret)
+ clk_core_unprepare_lock(core);
return ret;
}
-EXPORT_SYMBOL_GPL(clk_enable);
+
+static void clk_core_disable_unprepare(struct clk_core *core)
+{
+ clk_core_disable_lock(core);
+ clk_core_unprepare_lock(core);
+}
static unsigned long clk_core_round_rate_nolock(struct clk_core *core,
unsigned long rate,
--
1.9.1
next prev parent reply other threads:[~2015-05-14 14:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 13:28 [PATCH v2 0/5] clk: support clocks which requires parent clock on during operation Dong Aisheng
2015-05-14 13:28 ` [PATCH v2 1/5] clk: remove duplicated code with __clk_set_parent_after Dong Aisheng
2015-05-28 4:09 ` Michael Turquette
2015-05-28 8:25 ` Dong Aisheng
2015-07-15 12:25 ` Dong Aisheng
2015-07-15 12:29 ` Dong Aisheng
2015-07-22 14:08 ` Dong Aisheng
[not found] ` <20150724001135.642.54711@quantum>
2015-07-24 3:23 ` Dong Aisheng
2015-05-14 13:29 ` Dong Aisheng [this message]
2015-05-14 13:29 ` [PATCH v2 3/5] clk: move clk_disable_unused after clk_core_disable_unprepare function Dong Aisheng
2015-05-14 13:29 ` [PATCH v2 4/5] clk: core: add CLK_OPS_PARENT_ON flags to support clocks require parent on Dong Aisheng
2015-05-14 13:29 ` [PATCH v2 5/5] " Dong Aisheng
2015-05-20 11:42 ` [PATCH v2 0/5] clk: support clocks which requires parent clock on during operation Dong Aisheng
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=1431610143-21853-3-git-send-email-aisheng.dong@freescale.com \
--to=aisheng.dong@freescale.com \
--cc=Ranjani.Vaidyanathan@freescale.com \
--cc=b20596@freescale.com \
--cc=b20788@freescale.com \
--cc=b29396@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=r64343@freescale.com \
--cc=sboyd@codeaurora.org \
--cc=shawn.guo@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).