Skip to content

Commit

Permalink
clk: simplify clk_fetch_parent_index() function
Browse files Browse the repository at this point in the history
The clk_core_get_parent_by_index can be used as a helper function
to simplify the implementation of clk_fetch_parent_index().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
  • Loading branch information
Masahiro Yamada authored and Stephen Boyd committed Feb 2, 2016
1 parent 508f884 commit 470b5e2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,23 +1069,9 @@ static int clk_fetch_parent_index(struct clk_core *core,
if (!parent)
return -EINVAL;

/*
* find index of new parent clock using cached parent ptrs,
* or if not yet cached, use string name comparison and cache
* them now to avoid future calls to clk_core_lookup.
*/
for (i = 0; i < core->num_parents; i++) {
if (core->parents[i] == parent)
return i;

if (core->parents[i])
continue;

if (!strcmp(core->parent_names[i], parent->name)) {
core->parents[i] = clk_core_lookup(parent->name);
for (i = 0; i < core->num_parents; i++)
if (clk_core_get_parent_by_index(core, i) == parent)
return i;
}
}

return -EINVAL;
}
Expand Down

0 comments on commit 470b5e2

Please sign in to comment.