Skip to content

Commit

Permalink
clk: track the orphan status of clocks and their children
Browse files Browse the repository at this point in the history
While children of orphan clocks are not carried in the orphan-list itself,
they're nevertheless orphans in their own right as they also don't have an
input-rate available. To ease tracking if a clock is an orphan or has an
orphan in its parent path introduce an orphan field into struct clk and
update it and the fields in child-clocks when a clock gets added or removed
from the orphan-list.

Suggested-by: Stephen Boyd <[email protected]>
Signed-off-by: Heiko Stuebner <[email protected]>
Cc: Boris Brezillon <[email protected]>
Cc: Alex Elder <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Stephen Warren <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
Cc: Zhangfei Gao <[email protected]>
Cc: Santosh Shilimkar <[email protected]>
Cc: Chao Xie <[email protected]>
Cc: Jason Cooper <[email protected]>
Cc: Stefan Wahren <[email protected]>
Cc: Andrew Bresticker <[email protected]>
Cc: Robert Jarzmik <[email protected]>
Cc: Georgi Djakov <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Barry Song <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Gabriel FERNANDEZ <[email protected]>
Cc: [email protected]
Cc: Peter De Schrijver <[email protected]>
Cc: Tero Kristo <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Michal Simek <[email protected]>
[[email protected]: s/clk/core/ in new function]
Signed-off-by: Stephen Boyd <[email protected]>
  • Loading branch information
mmind authored and bebarino committed Aug 12, 2015
1 parent ee38b26 commit e650034
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct clk_core {
struct clk_core *new_parent;
struct clk_core *new_child;
unsigned long flags;
bool orphan;
unsigned int enable_count;
unsigned int prepare_count;
unsigned long min_rate;
Expand Down Expand Up @@ -1091,18 +1092,40 @@ static int clk_fetch_parent_index(struct clk_core *core,
return -EINVAL;
}

/*
* Update the orphan status of @core and all its children.
*/
static void clk_core_update_orphan_status(struct clk_core *core, bool is_orphan)
{
struct clk_core *child;

core->orphan = is_orphan;

hlist_for_each_entry(child, &core->children, child_node)
clk_core_update_orphan_status(child, is_orphan);
}

static void clk_reparent(struct clk_core *core, struct clk_core *new_parent)
{
bool was_orphan = core->orphan;

hlist_del(&core->child_node);

if (new_parent) {
bool becomes_orphan = new_parent->orphan;

/* avoid duplicate POST_RATE_CHANGE notifications */
if (new_parent->new_child == core)
new_parent->new_child = NULL;

hlist_add_head(&core->child_node, &new_parent->children);

if (was_orphan != becomes_orphan)
clk_core_update_orphan_status(core, becomes_orphan);
} else {
hlist_add_head(&core->child_node, &clk_orphan_list);
if (!was_orphan)
clk_core_update_orphan_status(core, true);
}

core->parent = new_parent;
Expand Down Expand Up @@ -2359,13 +2382,17 @@ static int __clk_init(struct device *dev, struct clk *clk_user)
* clocks and re-parent any that are children of the clock currently
* being clk_init'd.
*/
if (core->parent)
if (core->parent) {
hlist_add_head(&core->child_node,
&core->parent->children);
else if (core->flags & CLK_IS_ROOT)
core->orphan = core->parent->orphan;
} else if (core->flags & CLK_IS_ROOT) {
hlist_add_head(&core->child_node, &clk_root_list);
else
core->orphan = false;
} else {
hlist_add_head(&core->child_node, &clk_orphan_list);
core->orphan = true;
}

/*
* Set clk's accuracy. The preferred method is to use
Expand Down

0 comments on commit e650034

Please sign in to comment.