Skip to content

Commit 2d156b7

Browse files
committed
clk: Fix debugfs clk_possible_parents for clks without parent string names
Following the commit fc0c209 ("clk: Allow parents to be specified without string names"), the parent name string is not always populated. Instead, fetch the parents clk_core struct using the appropriate helper, and read its name directly. If that fails, go through the possible sources of parent names. The order in which they are used is different from how parents are looked up, with the global name having precedence over local fw_name and indices. This makes more sense as a) the parent_maps structure does not differentiate between legacy global names and fallback global names, and b) global names likely provide more information than local fw_names. Fixes: fc0c209 ("clk: Allow parents to be specified without string names") Signed-off-by: Chen-Yu Tsai <wens@csie.org>
1 parent a188339 commit 2d156b7

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

‎drivers/clk/clk.c‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,12 +3000,50 @@ DEFINE_SHOW_ATTRIBUTE(clk_flags);
30003000
static int possible_parents_show(struct seq_file *s, void *data)
30013001
{
30023002
struct clk_core *core = s->private;
3003+
struct clk_core *parent;
30033004
int i;
30043005

3005-
for (i = 0; i < core->num_parents - 1; i++)
3006-
seq_printf(s, "%s ", core->parents[i].name);
3006+
/*
3007+
* Go through the following options to fetch a parent's name.
3008+
*
3009+
* 1. Fetch the registered parent clock and use its name
3010+
* 2. Use the global (fallback) name if specified
3011+
* 3. Use the local fw_name if provided
3012+
* 4. Fetch parent clock's clock-output-name if DT index was set
3013+
*
3014+
* This may still fail in some cases, such as when the parent is
3015+
* specified directly via a struct clk_hw pointer, but it isn't
3016+
* registered (yet).
3017+
*/
3018+
for (i = 0; i < core->num_parents - 1; i++) {
3019+
parent = clk_core_get_parent_by_index(core, i);
3020+
if (parent)
3021+
seq_printf(s, "%s ", parent->name);
3022+
else if (core->parents[i].name)
3023+
seq_printf(s, "%s ", core->parents[i].name);
3024+
else if (core->parents[i].fw_name)
3025+
seq_printf(s, "<%s>(fw) ", core->parents[i].fw_name);
3026+
else if (core->parents[i].index >= 0)
3027+
seq_printf(s, "%s ",
3028+
of_clk_get_parent_name(core->of_node,
3029+
core->parents[i].index));
3030+
else
3031+
seq_puts(s, "(missing) ");
3032+
}
30073033

3008-
seq_printf(s, "%s\n", core->parents[i].name);
3034+
parent = clk_core_get_parent_by_index(core, i);
3035+
if (parent)
3036+
seq_printf(s, "%s", parent->name);
3037+
else if (core->parents[i].name)
3038+
seq_printf(s, "%s", core->parents[i].name);
3039+
else if (core->parents[i].fw_name)
3040+
seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
3041+
else if (core->parents[i].index >= 0)
3042+
seq_printf(s, "%s",
3043+
of_clk_get_parent_name(core->of_node,
3044+
core->parents[i].index));
3045+
else
3046+
seq_puts(s, "(missing)");
30093047

30103048
return 0;
30113049
}

0 commit comments

Comments
 (0)