diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2018-01-03 06:06:16 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2018-01-10 16:13:22 -0500 |
commit | a6059ab98130fb561157682d320c51c5ccd4b647 (patch) | |
tree | e990364caee2d7c1eac84fe200a490201c04cb3c | |
parent | f7ae75036762618ecc2cc7ae6fb4f6a74af92afb (diff) |
clk: Show symbolic clock flags in debugfs
Currently the virtual "clk_flags" file in debugfs shows the numeric
value of the top-level framework flags for the specified clock.
Hence the user must manually interpret these values.
Moreover, on big-endian 64-bit systems, the wrong half of the value is
shown, due to the cast from "unsigned long *" to "u32 *".
Fix both issues by showing the symbolic flag names instead.
Any non-standard flags are shown as a hex number.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r-- | drivers/clk/clk.c | 57 | ||||
-rw-r--r-- | include/linux/clk-provider.h | 2 |
2 files changed, 57 insertions, 2 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fe2d43e34216..479a3ee9cfe2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/pm_runtime.h> | 24 | #include <linux/pm_runtime.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/clkdev.h> | 26 | #include <linux/clkdev.h> |
27 | #include <linux/stringify.h> | ||
27 | 28 | ||
28 | #include "clk.h" | 29 | #include "clk.h" |
29 | 30 | ||
@@ -2554,6 +2555,58 @@ static const struct file_operations clk_dump_fops = { | |||
2554 | .release = single_release, | 2555 | .release = single_release, |
2555 | }; | 2556 | }; |
2556 | 2557 | ||
2558 | static const struct { | ||
2559 | unsigned long flag; | ||
2560 | const char *name; | ||
2561 | } clk_flags[] = { | ||
2562 | #define ENTRY(f) { f, __stringify(f) } | ||
2563 | ENTRY(CLK_SET_RATE_GATE), | ||
2564 | ENTRY(CLK_SET_PARENT_GATE), | ||
2565 | ENTRY(CLK_SET_RATE_PARENT), | ||
2566 | ENTRY(CLK_IGNORE_UNUSED), | ||
2567 | ENTRY(CLK_IS_BASIC), | ||
2568 | ENTRY(CLK_GET_RATE_NOCACHE), | ||
2569 | ENTRY(CLK_SET_RATE_NO_REPARENT), | ||
2570 | ENTRY(CLK_GET_ACCURACY_NOCACHE), | ||
2571 | ENTRY(CLK_RECALC_NEW_RATES), | ||
2572 | ENTRY(CLK_SET_RATE_UNGATE), | ||
2573 | ENTRY(CLK_IS_CRITICAL), | ||
2574 | ENTRY(CLK_OPS_PARENT_ENABLE), | ||
2575 | #undef ENTRY | ||
2576 | }; | ||
2577 | |||
2578 | static int clk_flags_dump(struct seq_file *s, void *data) | ||
2579 | { | ||
2580 | struct clk_core *core = s->private; | ||
2581 | unsigned long flags = core->flags; | ||
2582 | unsigned int i; | ||
2583 | |||
2584 | for (i = 0; flags && i < ARRAY_SIZE(clk_flags); i++) { | ||
2585 | if (flags & clk_flags[i].flag) { | ||
2586 | seq_printf(s, "%s\n", clk_flags[i].name); | ||
2587 | flags &= ~clk_flags[i].flag; | ||
2588 | } | ||
2589 | } | ||
2590 | if (flags) { | ||
2591 | /* Unknown flags */ | ||
2592 | seq_printf(s, "0x%lx\n", flags); | ||
2593 | } | ||
2594 | |||
2595 | return 0; | ||
2596 | } | ||
2597 | |||
2598 | static int clk_flags_open(struct inode *inode, struct file *file) | ||
2599 | { | ||
2600 | return single_open(file, clk_flags_dump, inode->i_private); | ||
2601 | } | ||
2602 | |||
2603 | static const struct file_operations clk_flags_fops = { | ||
2604 | .open = clk_flags_open, | ||
2605 | .read = seq_read, | ||
2606 | .llseek = seq_lseek, | ||
2607 | .release = single_release, | ||
2608 | }; | ||
2609 | |||
2557 | static int possible_parents_dump(struct seq_file *s, void *data) | 2610 | static int possible_parents_dump(struct seq_file *s, void *data) |
2558 | { | 2611 | { |
2559 | struct clk_core *core = s->private; | 2612 | struct clk_core *core = s->private; |
@@ -2610,8 +2663,8 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) | |||
2610 | if (!d) | 2663 | if (!d) |
2611 | goto err_out; | 2664 | goto err_out; |
2612 | 2665 | ||
2613 | d = debugfs_create_x32("clk_flags", S_IRUGO, core->dentry, | 2666 | d = debugfs_create_file("clk_flags", 0444, core->dentry, core, |
2614 | (u32 *)&core->flags); | 2667 | &clk_flags_fops); |
2615 | if (!d) | 2668 | if (!d) |
2616 | goto err_out; | 2669 | goto err_out; |
2617 | 2670 | ||
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 73ac87f34df9..c8236e948659 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
@@ -20,6 +20,8 @@ | |||
20 | * flags used across common struct clk. these flags should only affect the | 20 | * flags used across common struct clk. these flags should only affect the |
21 | * top-level framework. custom flags for dealing with hardware specifics | 21 | * top-level framework. custom flags for dealing with hardware specifics |
22 | * belong in struct clk_foo | 22 | * belong in struct clk_foo |
23 | * | ||
24 | * Please update clk_flags[] in drivers/clk/clk.c when making changes here! | ||
23 | */ | 25 | */ |
24 | #define CLK_SET_RATE_GATE BIT(0) /* must be gated across rate change */ | 26 | #define CLK_SET_RATE_GATE BIT(0) /* must be gated across rate change */ |
25 | #define CLK_SET_PARENT_GATE BIT(1) /* must be gated across re-parent */ | 27 | #define CLK_SET_PARENT_GATE BIT(1) /* must be gated across re-parent */ |