All of lore.kernel.org
 help / color / mirror / Atom feed
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 RFC v1 5/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions
Date: Wed, 15 Apr 2015 22:26:39 +0800	[thread overview]
Message-ID: <1429107999-24413-6-git-send-email-aisheng.dong@freescale.com> (raw)
In-Reply-To: <1429107999-24413-1-git-send-email-aisheng.dong@freescale.com>

This can be usefully 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.

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 | 79 +++++++++++++++++++++++++------------------------------
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f2470e5..6c481e7 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -48,6 +48,8 @@ static int clk_core_prepare(struct clk_core *clk);
 static void clk_core_unprepare(struct clk_core *clk);
 static int clk_core_enable(struct clk_core *clk);
 static void clk_core_disable(struct clk_core *clk);
+static int clk_core_enable_lock(struct clk_core *clk);
+static void clk_core_disable_lock(struct clk_core *clk);
 
 /***    private data structures    ***/
 
@@ -523,9 +525,7 @@ static void clk_disable_unused_subtree(struct clk_core *clk)
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
 		clk_core_prepare(parent->core);
-		flags = clk_enable_lock();
-		clk_core_enable(parent->core);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent->core);
 	}
 
 	flags = clk_enable_lock();
@@ -553,9 +553,7 @@ static void clk_disable_unused_subtree(struct clk_core *clk)
 unlock_out:
 	clk_enable_unlock(flags);
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
-		flags = clk_enable_lock();
-		clk_core_disable(parent->core);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(parent->core);
 		clk_core_unprepare(parent->core);
 	}
 }
@@ -1050,6 +1048,15 @@ static void clk_core_disable(struct clk_core *clk)
 	clk_core_disable(clk->parent);
 }
 
+static void clk_core_disable_lock(struct clk_core *clk)
+{
+	unsigned long flags;
+
+	flags = clk_enable_lock();
+	clk_core_disable(clk);
+	clk_enable_unlock(flags);
+}
+
 /**
  * clk_disable - gate a clock
  * @clk: the clk being gated
@@ -1108,6 +1115,18 @@ static int clk_core_enable(struct clk_core *clk)
 	return 0;
 }
 
+static int clk_core_enable_lock(struct clk_core *clk)
+{
+	unsigned long flags;
+	int ret;
+
+	flags = clk_enable_lock();
+	ret = clk_core_enable(clk);
+	clk_enable_unlock(flags);
+
+	return ret;
+}
+
 /**
  * clk_enable - ungate a clock
  * @clk: the clk being ungated
@@ -1489,20 +1508,13 @@ static struct clk_core *__clk_set_parent_before(struct clk_core *clk,
 	 */
 	if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
 		clk_core_prepare(parent);
-		flags = clk_enable_lock();
-		clk_core_enable(parent);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent);
 
 		if (clk->prepare_count) {
-			flags = clk_enable_lock();
-			clk_core_enable(clk);
-			clk_enable_unlock(flags);
+			clk_core_enable_lock(clk);
 		} else {
-
 			clk_core_prepare(old_parent);
-			flags = clk_enable_lock();
-			clk_core_enable(old_parent);
-			clk_enable_unlock(flags);
+			clk_core_enable_lock(old_parent);
 		}
 	}
 
@@ -1518,26 +1530,18 @@ static void __clk_set_parent_after(struct clk_core *clk,
 				   struct clk_core *parent,
 				   struct clk_core *old_parent)
 {
-	unsigned long flags;
-
 	/*
 	 * Finish the migration of prepare state and undo the changes done
 	 * for preventing a race with clk_enable().
 	 */
 	if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
-		flags = clk_enable_lock();
-		clk_core_disable(old_parent);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(old_parent);
 		clk_core_unprepare(old_parent);
 
 		if (clk->prepare_count) {
-			flags = clk_enable_lock();
-			clk_core_disable(clk);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(clk);
 		} else {
-			flags = clk_enable_lock();
-			clk_core_disable(parent);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(parent);
 			clk_core_unprepare(parent);
 		}
 	}
@@ -1566,19 +1570,13 @@ static int __clk_set_parent(struct clk_core *clk, struct clk_core *parent,
 		clk_enable_unlock(flags);
 
 		if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
-			flags = clk_enable_lock();
-			clk_core_disable(parent);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(parent);
 			clk_core_unprepare(parent);
 
 			if (clk->prepare_count) {
-				flags = clk_enable_lock();
-				clk_core_disable(clk);
-				clk_enable_unlock(flags);
+				clk_core_disable_lock(clk);
 			} else {
-				flags = clk_enable_lock();
-				clk_core_disable(old_parent);
-				clk_enable_unlock(flags);
+				clk_core_disable_lock(old_parent);
 				clk_core_unprepare(old_parent);
 			}
 
@@ -1798,7 +1796,6 @@ static void clk_change_rate(struct clk_core *clk)
 	bool skip_set_rate = false;
 	struct clk_core *old_parent;
 	struct clk_core *parent = NULL;
-	unsigned long flags;
 
 	old_rate = clk->rate;
 
@@ -1831,9 +1828,7 @@ static void clk_change_rate(struct clk_core *clk)
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
 		clk_core_prepare(parent);
-		flags = clk_enable_lock();
-		clk_core_enable(parent);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent);
 	}
 
 	if (!skip_set_rate && clk->ops->set_rate)
@@ -1844,9 +1839,7 @@ static void clk_change_rate(struct clk_core *clk)
 	clk->rate = clk_recalc(clk, best_parent_rate);
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
-		flags = clk_enable_lock();
-		clk_core_disable(parent);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(parent);
 		clk_core_unprepare(parent);
 	}
 
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: aisheng.dong@freescale.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC v1 5/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions
Date: Wed, 15 Apr 2015 22:26:39 +0800	[thread overview]
Message-ID: <1429107999-24413-6-git-send-email-aisheng.dong@freescale.com> (raw)
In-Reply-To: <1429107999-24413-1-git-send-email-aisheng.dong@freescale.com>

This can be usefully 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.

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 | 79 +++++++++++++++++++++++++------------------------------
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f2470e5..6c481e7 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -48,6 +48,8 @@ static int clk_core_prepare(struct clk_core *clk);
 static void clk_core_unprepare(struct clk_core *clk);
 static int clk_core_enable(struct clk_core *clk);
 static void clk_core_disable(struct clk_core *clk);
+static int clk_core_enable_lock(struct clk_core *clk);
+static void clk_core_disable_lock(struct clk_core *clk);
 
 /***    private data structures    ***/
 
@@ -523,9 +525,7 @@ static void clk_disable_unused_subtree(struct clk_core *clk)
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
 		clk_core_prepare(parent->core);
-		flags = clk_enable_lock();
-		clk_core_enable(parent->core);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent->core);
 	}
 
 	flags = clk_enable_lock();
@@ -553,9 +553,7 @@ static void clk_disable_unused_subtree(struct clk_core *clk)
 unlock_out:
 	clk_enable_unlock(flags);
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
-		flags = clk_enable_lock();
-		clk_core_disable(parent->core);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(parent->core);
 		clk_core_unprepare(parent->core);
 	}
 }
@@ -1050,6 +1048,15 @@ static void clk_core_disable(struct clk_core *clk)
 	clk_core_disable(clk->parent);
 }
 
+static void clk_core_disable_lock(struct clk_core *clk)
+{
+	unsigned long flags;
+
+	flags = clk_enable_lock();
+	clk_core_disable(clk);
+	clk_enable_unlock(flags);
+}
+
 /**
  * clk_disable - gate a clock
  * @clk: the clk being gated
@@ -1108,6 +1115,18 @@ static int clk_core_enable(struct clk_core *clk)
 	return 0;
 }
 
+static int clk_core_enable_lock(struct clk_core *clk)
+{
+	unsigned long flags;
+	int ret;
+
+	flags = clk_enable_lock();
+	ret = clk_core_enable(clk);
+	clk_enable_unlock(flags);
+
+	return ret;
+}
+
 /**
  * clk_enable - ungate a clock
  * @clk: the clk being ungated
@@ -1489,20 +1508,13 @@ static struct clk_core *__clk_set_parent_before(struct clk_core *clk,
 	 */
 	if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
 		clk_core_prepare(parent);
-		flags = clk_enable_lock();
-		clk_core_enable(parent);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent);
 
 		if (clk->prepare_count) {
-			flags = clk_enable_lock();
-			clk_core_enable(clk);
-			clk_enable_unlock(flags);
+			clk_core_enable_lock(clk);
 		} else {
-
 			clk_core_prepare(old_parent);
-			flags = clk_enable_lock();
-			clk_core_enable(old_parent);
-			clk_enable_unlock(flags);
+			clk_core_enable_lock(old_parent);
 		}
 	}
 
@@ -1518,26 +1530,18 @@ static void __clk_set_parent_after(struct clk_core *clk,
 				   struct clk_core *parent,
 				   struct clk_core *old_parent)
 {
-	unsigned long flags;
-
 	/*
 	 * Finish the migration of prepare state and undo the changes done
 	 * for preventing a race with clk_enable().
 	 */
 	if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
-		flags = clk_enable_lock();
-		clk_core_disable(old_parent);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(old_parent);
 		clk_core_unprepare(old_parent);
 
 		if (clk->prepare_count) {
-			flags = clk_enable_lock();
-			clk_core_disable(clk);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(clk);
 		} else {
-			flags = clk_enable_lock();
-			clk_core_disable(parent);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(parent);
 			clk_core_unprepare(parent);
 		}
 	}
@@ -1566,19 +1570,13 @@ static int __clk_set_parent(struct clk_core *clk, struct clk_core *parent,
 		clk_enable_unlock(flags);
 
 		if (clk->prepare_count || clk->flags & CLK_SET_PARENT_ON) {
-			flags = clk_enable_lock();
-			clk_core_disable(parent);
-			clk_enable_unlock(flags);
+			clk_core_disable_lock(parent);
 			clk_core_unprepare(parent);
 
 			if (clk->prepare_count) {
-				flags = clk_enable_lock();
-				clk_core_disable(clk);
-				clk_enable_unlock(flags);
+				clk_core_disable_lock(clk);
 			} else {
-				flags = clk_enable_lock();
-				clk_core_disable(old_parent);
-				clk_enable_unlock(flags);
+				clk_core_disable_lock(old_parent);
 				clk_core_unprepare(old_parent);
 			}
 
@@ -1798,7 +1796,6 @@ static void clk_change_rate(struct clk_core *clk)
 	bool skip_set_rate = false;
 	struct clk_core *old_parent;
 	struct clk_core *parent = NULL;
-	unsigned long flags;
 
 	old_rate = clk->rate;
 
@@ -1831,9 +1828,7 @@ static void clk_change_rate(struct clk_core *clk)
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
 		clk_core_prepare(parent);
-		flags = clk_enable_lock();
-		clk_core_enable(parent);
-		clk_enable_unlock(flags);
+		clk_core_enable_lock(parent);
 	}
 
 	if (!skip_set_rate && clk->ops->set_rate)
@@ -1844,9 +1839,7 @@ static void clk_change_rate(struct clk_core *clk)
 	clk->rate = clk_recalc(clk, best_parent_rate);
 
 	if (clk->flags & CLK_SET_PARENT_ON && parent) {
-		flags = clk_enable_lock();
-		clk_core_disable(parent);
-		clk_enable_unlock(flags);
+		clk_core_disable_lock(parent);
 		clk_core_unprepare(parent);
 	}
 
-- 
1.9.1

  parent reply	other threads:[~2015-04-15 14:29 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 14:26 [PATCH RFC v1 0/5] clk: support clocks which requires parent clock on during operation Dong Aisheng
2015-04-15 14:26 ` Dong Aisheng
2015-04-15 14:26 ` [PATCH RFC v1 1/5] clk: change clk_core name of __clk_set_parent_after Dong Aisheng
2015-04-15 14:26   ` Dong Aisheng
2015-04-30 19:06   ` Stephen Boyd
2015-04-30 19:06     ` Stephen Boyd
2015-05-04  8:15     ` Dong Aisheng
2015-05-04  8:15       ` Dong Aisheng
2015-04-15 14:26 ` [PATCH RFC v1 2/5] clk: add missing lock when call clk_core_enable in clk_set_parent Dong Aisheng
2015-04-15 14:26   ` Dong Aisheng
2015-04-30 19:07   ` Stephen Boyd
2015-04-30 19:07     ` Stephen Boyd
2015-05-04  8:35     ` Dong Aisheng
2015-05-04  8:35       ` Dong Aisheng
2015-05-07  0:01       ` Stephen Boyd
2015-05-07  0:01         ` Stephen Boyd
2015-05-13  9:21         ` Dong Aisheng
2015-05-13  9:21           ` Dong Aisheng
2015-04-15 14:26 ` [PATCH RFC v1 3/5] clk: remove unneeded __clk_enable and __clk_disable Dong Aisheng
2015-04-15 14:26   ` Dong Aisheng
2015-04-30 19:09   ` Stephen Boyd
2015-04-30 19:09     ` Stephen Boyd
2015-04-30 22:05     ` Stephen Boyd
2015-04-30 22:05       ` Stephen Boyd
2015-05-04  8:16       ` Dong Aisheng
2015-05-04  8:16         ` Dong Aisheng
2015-04-15 14:26 ` [PATCH RFC v1 4/5] clk: core: add CLK_SET_PARENT_ON flags to support clocks require parent on Dong Aisheng
2015-04-15 14:26   ` Dong Aisheng
2015-05-01  1:09   ` Stephen Boyd
2015-05-01  1:09     ` Stephen Boyd
2015-05-04 10:36     ` Dong Aisheng
2015-05-04 10:36       ` Dong Aisheng
2015-05-06 23:34       ` Stephen Boyd
2015-05-06 23:34         ` Stephen Boyd
2015-05-13  9:20         ` Dong Aisheng
2015-05-13  9:20           ` Dong Aisheng
2015-04-15 14:26 ` Dong Aisheng [this message]
2015-04-15 14:26   ` [PATCH RFC v1 5/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Dong Aisheng
2015-05-01  1:10   ` Stephen Boyd
2015-05-01  1:10     ` Stephen Boyd
2015-05-04 10:38     ` Dong Aisheng
2015-05-04 10:38       ` Dong Aisheng
2015-04-22  6:12 ` [PATCH RFC v1 0/5] clk: support clocks which requires parent clock on during operation Dong Aisheng
2015-04-22  6:12   ` Dong Aisheng
2015-04-30  2:37   ` Dong Aisheng
2015-04-30  2:37     ` 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=1429107999-24413-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.