Skip to content

Commit 11f6c23

Browse files
committed
clk: Simplify debugfs printing and add a newline
The possible parent printing function duplicates a bunch of if conditions. Pull that into another function so we can print an extra character at the end, either a space or a newline. This way we can add the required newline that got lost here and also shorten the code. Fixes: 2d156b7 ("clk: Fix debugfs clk_possible_parents for clks without parent string names") Cc: Chen-Yu Tsai <wens@csie.org> Tested-by: Chen-Yu Tsai <wens@csie.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent f925a05 commit 11f6c23

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

‎drivers/clk/clk.c‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,11 +2997,10 @@ static int clk_flags_show(struct seq_file *s, void *data)
29972997
}
29982998
DEFINE_SHOW_ATTRIBUTE(clk_flags);
29992999

3000-
static int possible_parents_show(struct seq_file *s, void *data)
3000+
static void possible_parent_show(struct seq_file *s, struct clk_core *core,
3001+
unsigned int i, char terminator)
30013002
{
3002-
struct clk_core *core = s->private;
30033003
struct clk_core *parent;
3004-
int i;
30053004

30063005
/*
30073006
* Go through the following options to fetch a parent's name.
@@ -3015,22 +3014,6 @@ static int possible_parents_show(struct seq_file *s, void *data)
30153014
* specified directly via a struct clk_hw pointer, but it isn't
30163015
* registered (yet).
30173016
*/
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-
}
3033-
30343017
parent = clk_core_get_parent_by_index(core, i);
30353018
if (parent)
30363019
seq_printf(s, "%s", parent->name);
@@ -3045,6 +3028,19 @@ static int possible_parents_show(struct seq_file *s, void *data)
30453028
else
30463029
seq_puts(s, "(missing)");
30473030

3031+
seq_putc(s, terminator);
3032+
}
3033+
3034+
static int possible_parents_show(struct seq_file *s, void *data)
3035+
{
3036+
struct clk_core *core = s->private;
3037+
int i;
3038+
3039+
for (i = 0; i < core->num_parents - 1; i++)
3040+
possible_parent_show(s, core, i, ' ');
3041+
3042+
possible_parent_show(s, core, i, '\n');
3043+
30483044
return 0;
30493045
}
30503046
DEFINE_SHOW_ATTRIBUTE(possible_parents);

0 commit comments

Comments
 (0)