diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-05-11 16:51:05 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-05-11 16:51:05 -0400 |
commit | aa87aa343f2cd236b5eccd643abd4df918ed5c4f (patch) | |
tree | 2a6dbd7be7f6ce9d00c0800e8a10a7cb7ed7c7d1 /arch/sh/kernel | |
parent | ae891a4264c91246c0b4c22be68b9838747ae48d (diff) |
sh: clkfwk: Improve the generic clk_set_parent() implementation.
This causes the generic clk_set_parent() implementation to be a bit more
intelligent. A clk_reparent() is added to move the clock over to the new
parent's sibling list, which then allows the generic rate propagation
code to succeed. This also becomes a nop if the new and old parents are
unchanged.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel')
-rw-r--r-- | arch/sh/kernel/cpu/clock.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c index e027fe5898d6..e3d1de8a46fd 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c | |||
@@ -81,6 +81,19 @@ unsigned long followparent_recalc(struct clk *clk) | |||
81 | return clk->parent->rate; | 81 | return clk->parent->rate; |
82 | } | 82 | } |
83 | 83 | ||
84 | int clk_reparent(struct clk *child, struct clk *parent) | ||
85 | { | ||
86 | list_del_init(&child->sibling); | ||
87 | if (parent) | ||
88 | list_add(&child->sibling, &parent->children); | ||
89 | child->parent = parent; | ||
90 | |||
91 | /* now do the debugfs renaming to reattach the child | ||
92 | to the proper parent */ | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
84 | /* Propagate rate to children */ | 97 | /* Propagate rate to children */ |
85 | void propagate_rate(struct clk *tclk) | 98 | void propagate_rate(struct clk *tclk) |
86 | { | 99 | { |
@@ -288,12 +301,19 @@ int clk_set_parent(struct clk *clk, struct clk *parent) | |||
288 | 301 | ||
289 | if (!parent || !clk) | 302 | if (!parent || !clk) |
290 | return ret; | 303 | return ret; |
304 | if (clk->parent == parent) | ||
305 | return 0; | ||
291 | 306 | ||
292 | spin_lock_irqsave(&clock_lock, flags); | 307 | spin_lock_irqsave(&clock_lock, flags); |
293 | if (clk->usecount == 0) { | 308 | if (clk->usecount == 0) { |
294 | if (clk->ops->set_parent) | 309 | if (clk->ops->set_parent) |
295 | ret = clk->ops->set_parent(clk, parent); | 310 | ret = clk->ops->set_parent(clk, parent); |
311 | else | ||
312 | ret = clk_reparent(clk, parent); | ||
313 | |||
296 | if (ret == 0) { | 314 | if (ret == 0) { |
315 | pr_debug("clock: set parent of %s to %s (new rate %ld)\n", | ||
316 | clk->name, clk->parent->name, clk->rate); | ||
297 | if (clk->ops->recalc) | 317 | if (clk->ops->recalc) |
298 | clk->rate = clk->ops->recalc(clk); | 318 | clk->rate = clk->ops->recalc(clk); |
299 | propagate_rate(clk); | 319 | propagate_rate(clk); |