diff options
author | Stephen Boyd <sboyd@kernel.org> | 2019-06-24 23:01:55 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2019-06-25 14:56:04 -0400 |
commit | 11f6c2307caee89370d7752eb6f404f1ed73faaf (patch) | |
tree | a396f5fb90bb92766d1b60c252eb1a69ba17dbf4 /drivers/clk/clk.c | |
parent | f925a054f0f85c93282f6ddab0e1355237293214 (diff) |
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: 2d156b78ce8f ("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>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 093161ca4dcc..09d8e84a1968 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -2997,11 +2997,10 @@ static int clk_flags_show(struct seq_file *s, void *data) | |||
2997 | } | 2997 | } |
2998 | DEFINE_SHOW_ATTRIBUTE(clk_flags); | 2998 | DEFINE_SHOW_ATTRIBUTE(clk_flags); |
2999 | 2999 | ||
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) | ||
3001 | { | 3002 | { |
3002 | struct clk_core *core = s->private; | ||
3003 | struct clk_core *parent; | 3003 | struct clk_core *parent; |
3004 | int i; | ||
3005 | 3004 | ||
3006 | /* | 3005 | /* |
3007 | * Go through the following options to fetch a parent's name. | 3006 | * 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) | |||
3015 | * specified directly via a struct clk_hw pointer, but it isn't | 3014 | * specified directly via a struct clk_hw pointer, but it isn't |
3016 | * registered (yet). | 3015 | * registered (yet). |
3017 | */ | 3016 | */ |
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 | |||
3034 | parent = clk_core_get_parent_by_index(core, i); | 3017 | parent = clk_core_get_parent_by_index(core, i); |
3035 | if (parent) | 3018 | if (parent) |
3036 | seq_printf(s, "%s", parent->name); | 3019 | seq_printf(s, "%s", parent->name); |
@@ -3045,6 +3028,19 @@ static int possible_parents_show(struct seq_file *s, void *data) | |||
3045 | else | 3028 | else |
3046 | seq_puts(s, "(missing)"); | 3029 | seq_puts(s, "(missing)"); |
3047 | 3030 | ||
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 | |||
3048 | return 0; | 3044 | return 0; |
3049 | } | 3045 | } |
3050 | DEFINE_SHOW_ATTRIBUTE(possible_parents); | 3046 | DEFINE_SHOW_ATTRIBUTE(possible_parents); |