diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2015-12-28 11:23:04 +0100 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2016-02-02 20:53:10 +0100 |
commit | 5146e0b05963f75347c9f4e18996da245f859e32 (patch) | |
tree | dfd3f47d3f455d82f5eb741cf63595fd24d3189f /drivers/clk/clk.c | |
parent | clk: move checking .get_parent to __clk_core_init() (diff) | |
download | linux-5146e0b05963f75347c9f4e18996da245f859e32.tar.xz linux-5146e0b05963f75347c9f4e18996da245f859e32.zip |
clk: simplify __clk_init_parent()
The translation from the index into clk_core is done by
clk_core_get_parent_by_index(). The if-block for num_parents == 1
case is duplicating the code in the clk_core_get_parent_by_index().
Drop the "if (num_parents == 1)" from the special case. Instead,
set the index to zero if .get_parent() is missing.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7fe94a5c6b4a..dee9c528ea83 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1669,44 +1669,14 @@ struct clk *clk_get_parent(struct clk *clk) } EXPORT_SYMBOL_GPL(clk_get_parent); -/* - * .get_parent is mandatory for clocks with multiple possible parents. It is - * optional for single-parent clocks. Always call .get_parent if it is - * available and WARN if it is missing for multi-parent clocks. - * - * For single-parent clocks without .get_parent, first check to see if the - * .parents array exists, and if so use it to avoid an expensive tree - * traversal. If .parents does not exist then walk the tree. - */ static struct clk_core *__clk_init_parent(struct clk_core *core) { - struct clk_core *ret = NULL; - u8 index; - - /* handle the trivial cases */ + u8 index = 0; - if (!core->num_parents) - goto out; - - if (core->num_parents == 1) { - if (IS_ERR_OR_NULL(core->parent)) - core->parent = clk_core_lookup(core->parent_names[0]); - ret = core->parent; - goto out; - } + if (core->ops->get_parent) + index = core->ops->get_parent(core->hw); - /* - * Do our best to cache parent clocks in core->parents. This prevents - * unnecessary and expensive lookups. We don't set core->parent here; - * that is done by the calling function. - */ - - index = core->ops->get_parent(core->hw); - - ret = clk_core_get_parent_by_index(core, index); - -out: - return ret; + return clk_core_get_parent_by_index(core, index); } static void clk_core_reparent(struct clk_core *core, |