Skip to content

Commit

Permalink
sh: call clock framework init() callback once
Browse files Browse the repository at this point in the history
Make sure that clk->ops->init() only gets called once in
the case of CLK_ALWAYS_ENABLED. Without this patch the
init() callback may be called multiple times.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Magnus Damm authored and Paul Mundt committed May 8, 2009
1 parent 5dafc91 commit b3cacf3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/sh/kernel/cpu/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ static int __clk_enable(struct clk *clk)
* changes and the clock needs to hunt for the proper set of
* divisors to use before it can effectively recalc.
*/

if (clk->flags & CLK_ALWAYS_ENABLED) {
kref_get(&clk->kref);
return 0;
}

if (unlikely(atomic_read(&clk->kref.refcount) == 1))
if (clk->ops && clk->ops->init)
clk->ops->init(clk);

kref_get(&clk->kref);

if (clk->flags & CLK_ALWAYS_ENABLED)
return 0;

if (likely(clk->ops && clk->ops->enable))
clk->ops->enable(clk);

Expand Down

0 comments on commit b3cacf3

Please sign in to comment.