From: Rajagopal Venkat <rajagopal.venkat@linaro.org>
To: mturquette@linaro.org
Cc: patches@linaro.org, linaro-dev@lists.linaro.org,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Rajagopal Venkat <rajagopal.venkat@linaro.org>
Subject: [PATCH] clk: allow reparenting of a clock to the orphan list
Date: Mon, 21 Jan 2013 18:33:57 +0530 [thread overview]
Message-ID: <1358773437-21163-1-git-send-email-rajagopal.venkat@linaro.org> (raw)
Allow reparenting of a clock(multiple and single parent)
to the orphan list when new parent clock is NULL.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>
---
drivers/clk/clk.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index e964994..5c9277a 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1102,7 +1102,7 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent)
struct dentry *new_parent_d;
#endif
- if (!clk || !new_parent)
+ if (!clk)
return;
hlist_del(&clk->child_node);
@@ -1140,11 +1140,14 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
{
struct clk *old_parent;
unsigned long flags;
- int ret = -EINVAL;
- u8 i;
+ int ret = 0;
+ u8 i = 0;
old_parent = clk->parent;
+ if (clk->num_parents == 1 || !parent)
+ goto migrate;
+
if (!clk->parents)
clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
GFP_KERNEL);
@@ -1165,11 +1168,13 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
}
if (i == clk->num_parents) {
+ ret = -EINVAL;
pr_debug("%s: clock %s is not a possible parent of clock %s\n",
__func__, parent->name, clk->name);
goto out;
}
+migrate:
/* migrate prepare and enable */
if (clk->prepare_count)
__clk_prepare(parent);
@@ -1181,7 +1186,8 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
spin_unlock_irqrestore(&enable_lock, flags);
/* change clock input source */
- ret = clk->ops->set_parent(clk->hw, i);
+ if (clk->ops->set_parent)
+ ret = clk->ops->set_parent(clk->hw, i);
/* clean up old prepare and enable */
spin_lock_irqsave(&enable_lock, flags);
@@ -1215,7 +1221,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
if (!clk || !clk->ops)
return -EINVAL;
- if (!clk->ops->set_parent)
+ if (clk->num_parents > 1 && !clk->ops->set_parent)
return -ENOSYS;
/* prevent racing with updates to the clock topology */
@@ -1226,7 +1232,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
/* propagate PRE_RATE_CHANGE notifications */
if (clk->notifier_count)
- ret = __clk_speculate_rates(clk, parent->rate);
+ ret = __clk_speculate_rates(clk, parent ? parent->rate : 0);
/* abort if a driver objects */
if (ret == NOTIFY_STOP)
--
1.7.10.4
reply other threads:[~2013-01-21 13:08 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=1358773437-21163-1-git-send-email-rajagopal.venkat@linaro.org \
--to=rajagopal.venkat@linaro.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=patches@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).