Skip to content

Commit

Permalink
clk: call the clock init() callback before any other ops callback
Browse files Browse the repository at this point in the history
Some clocks may need to initialize things, whatever it is, before
being able to properly operate. Move the .init() call before any
other callback, such recalc_rate() or get_phase(), so the clock
is properly setup before being used.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Jerome Brunet authored and Stephen Boyd committed Mar 12, 2018
1 parent 77deb66 commit 541deba
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,17 @@ static int __clk_core_init(struct clk_core *core)
core->orphan = true;
}

/*
* optional platform-specific magic
*
* The .init callback is not used by any of the basic clock types, but
* exists for weird hardware that must perform initialization magic.
* Please consider other ways of solving initialization problems before
* using this callback, as its use is discouraged.
*/
if (core->ops->init)
core->ops->init(core->hw);

/*
* Set clk's accuracy. The preferred method is to use
* .recalc_accuracy. For simple clocks and lazy developers the default
Expand Down Expand Up @@ -3006,17 +3017,6 @@ static int __clk_core_init(struct clk_core *core)
}
}

/*
* optional platform-specific magic
*
* The .init callback is not used by any of the basic clock types, but
* exists for weird hardware that must perform initialization magic.
* Please consider other ways of solving initialization problems before
* using this callback, as its use is discouraged.
*/
if (core->ops->init)
core->ops->init(core->hw);

kref_init(&core->ref);
out:
clk_pm_runtime_put(core);
Expand Down

0 comments on commit 541deba

Please sign in to comment.