All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Mike Turquette <mturquette@linaro.org>,
	<linux-arm-kernel@lists.infradead.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>,
	<linux-kernel@vger.kernel.org>,
	Saravana Kannan <skannan@codeaurora.org>,
	Doug Anderson <dianders@chromium.org>,
	James Hogan <james.hogan@imgtec.com>
Subject: [PATCH v5 1/5] clk: abstract parent cache
Date: Thu, 13 Jun 2013 17:05:58 +0100	[thread overview]
Message-ID: <1371139562-305-2-git-send-email-james.hogan@imgtec.com> (raw)
In-Reply-To: <1371139562-305-1-git-send-email-james.hogan@imgtec.com>

Abstract access to the clock parent cache by defining
clk_get_parent_by_index(clk, index). This allows access to parent
clocks from clock drivers.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
---
Changes in v3:

* remove double underscore prefix from clk_get_parent_by_index()

 drivers/clk/clk.c            | 21 ++++++++++++++-------
 include/linux/clk-provider.h |  1 +
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index af0dbcc..ce74e91 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -559,6 +559,19 @@ struct clk *__clk_get_parent(struct clk *clk)
 	return !clk ? NULL : clk->parent;
 }
 
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
+{
+	if (!clk || index >= clk->num_parents)
+		return NULL;
+	else if (!clk->parents)
+		return __clk_lookup(clk->parent_names[index]);
+	else if (!clk->parents[index])
+		return clk->parents[index] =
+			__clk_lookup(clk->parent_names[index]);
+	else
+		return clk->parents[index];
+}
+
 unsigned int __clk_get_enable_count(struct clk *clk)
 {
 	return !clk ? 0 : clk->enable_count;
@@ -1315,13 +1328,7 @@ static struct clk *__clk_init_parent(struct clk *clk)
 			kzalloc((sizeof(struct clk*) * clk->num_parents),
 					GFP_KERNEL);
 
-	if (!clk->parents)
-		ret = __clk_lookup(clk->parent_names[index]);
-	else if (!clk->parents[index])
-		ret = clk->parents[index] =
-			__clk_lookup(clk->parent_names[index]);
-	else
-		ret = clk->parents[index];
+	ret = clk_get_parent_by_index(clk, index);
 
 out:
 	return ret;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 265f384..feff375 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -403,6 +403,7 @@ const char *__clk_get_name(struct clk *clk);
 struct clk_hw *__clk_get_hw(struct clk *clk);
 u8 __clk_get_num_parents(struct clk *clk);
 struct clk *__clk_get_parent(struct clk *clk);
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
 unsigned int __clk_get_enable_count(struct clk *clk);
 unsigned int __clk_get_prepare_count(struct clk *clk);
 unsigned long __clk_get_rate(struct clk *clk);
-- 
1.8.1.2



WARNING: multiple messages have this Message-ID (diff)
From: james.hogan@imgtec.com (James Hogan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 1/5] clk: abstract parent cache
Date: Thu, 13 Jun 2013 17:05:58 +0100	[thread overview]
Message-ID: <1371139562-305-2-git-send-email-james.hogan@imgtec.com> (raw)
In-Reply-To: <1371139562-305-1-git-send-email-james.hogan@imgtec.com>

Abstract access to the clock parent cache by defining
clk_get_parent_by_index(clk, index). This allows access to parent
clocks from clock drivers.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: linux-arm-kernel at lists.infradead.org
---
Changes in v3:

* remove double underscore prefix from clk_get_parent_by_index()

 drivers/clk/clk.c            | 21 ++++++++++++++-------
 include/linux/clk-provider.h |  1 +
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index af0dbcc..ce74e91 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -559,6 +559,19 @@ struct clk *__clk_get_parent(struct clk *clk)
 	return !clk ? NULL : clk->parent;
 }
 
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
+{
+	if (!clk || index >= clk->num_parents)
+		return NULL;
+	else if (!clk->parents)
+		return __clk_lookup(clk->parent_names[index]);
+	else if (!clk->parents[index])
+		return clk->parents[index] =
+			__clk_lookup(clk->parent_names[index]);
+	else
+		return clk->parents[index];
+}
+
 unsigned int __clk_get_enable_count(struct clk *clk)
 {
 	return !clk ? 0 : clk->enable_count;
@@ -1315,13 +1328,7 @@ static struct clk *__clk_init_parent(struct clk *clk)
 			kzalloc((sizeof(struct clk*) * clk->num_parents),
 					GFP_KERNEL);
 
-	if (!clk->parents)
-		ret = __clk_lookup(clk->parent_names[index]);
-	else if (!clk->parents[index])
-		ret = clk->parents[index] =
-			__clk_lookup(clk->parent_names[index]);
-	else
-		ret = clk->parents[index];
+	ret = clk_get_parent_by_index(clk, index);
 
 out:
 	return ret;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 265f384..feff375 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -403,6 +403,7 @@ const char *__clk_get_name(struct clk *clk);
 struct clk_hw *__clk_get_hw(struct clk *clk);
 u8 __clk_get_num_parents(struct clk *clk);
 struct clk *__clk_get_parent(struct clk *clk);
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
 unsigned int __clk_get_enable_count(struct clk *clk);
 unsigned int __clk_get_prepare_count(struct clk *clk);
 unsigned long __clk_get_rate(struct clk *clk);
-- 
1.8.1.2

  reply	other threads:[~2013-06-13 16:13 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-13 16:05 [PATCH v5 0/5] clk: implement remuxing during set_rate James Hogan
2013-06-13 16:05 ` James Hogan
2013-06-13 16:05 ` James Hogan [this message]
2013-06-13 16:05   ` [PATCH v5 1/5] clk: abstract parent cache James Hogan
2013-06-13 16:05 ` [PATCH v5 2/5] clk: move some parent related functions upwards James Hogan
2013-06-13 16:05   ` James Hogan
2013-06-13 16:06 ` [PATCH v5 3/5] clk: add support for clock reparent on set_rate James Hogan
2013-06-13 16:06   ` James Hogan
2013-06-13 16:06 ` [PATCH v5 4/5] clk: add CLK_SET_RATE_NO_REPARENT flag James Hogan
2013-06-13 16:06   ` James Hogan
2013-06-13 16:06   ` James Hogan
2013-07-25 12:34   ` Sylwester Nawrocki
2013-07-25 12:34     ` Sylwester Nawrocki
2013-07-25 12:34     ` Sylwester Nawrocki
2013-07-25 12:55     ` James Hogan
2013-07-25 12:55       ` James Hogan
2013-07-25 12:55       ` James Hogan
2013-07-25 18:05       ` Mike Turquette
2013-07-25 18:05         ` Mike Turquette
2013-07-25 18:05         ` Mike Turquette
2013-06-13 16:06 ` [PATCH v5 5/5] clk: clk-mux: implement remuxing on set_rate James Hogan
2013-06-13 16:06   ` James Hogan
2013-06-21 17:04 ` [PATCH v5 0/5] clk: implement remuxing during set_rate Mike Turquette
2013-06-21 17:04   ` Mike Turquette
2013-06-21 21:27   ` James Hogan
2013-06-21 21:27     ` James Hogan
2013-07-24 18:39     ` Stephen Boyd
2013-07-24 18:39       ` Stephen Boyd
2013-07-25  9:07       ` James Hogan
2013-07-25  9:07         ` James Hogan

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=1371139562-305-2-git-send-email-james.hogan@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=dianders@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=sboyd@codeaurora.org \
    --cc=skannan@codeaurora.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.