[1/7] debugfs: Extend debugfs regset to support register decoding
Commit Message
Allow regsets to provide a function to present decoded information on
register usage. This allows a static function to be passed the value
read from the register and present the information in a human readable
form.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
This is purely RFC / Personal debug use only.
- I'm not currently recommending/suggesting/asking for this change to
the core debugfs infrastructure.
- I have not put effort into design, or thought about how this should be
done, this is just something I use locally as a quick hack.
- I would likely use https://github.com/tomba/rwmem if I were to tackle
this again now.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
fs/debugfs/file.c | 11 +++++++++--
include/linux/debugfs.h | 1 +
2 files changed, 10 insertions(+), 2 deletions(-)
@@ -1111,10 +1111,17 @@ void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
int i;
for (i = 0; i < nregs; i++, regs++) {
+ u32 value = readl(base + regs->offset);
if (prefix)
seq_printf(s, "%s", prefix);
- seq_printf(s, "%s = 0x%08x\n", regs->name,
- readl(base + regs->offset));
+
+ seq_printf(s, "%s = 0x%08x", regs->name, value);
+
+ if (regs->decode_reg)
+ regs->decode_reg(s, value);
+
+ seq_puts(s, "\n");
+
if (seq_has_overflowed(s))
break;
}
@@ -29,6 +29,7 @@ struct debugfs_blob_wrapper {
struct debugfs_reg32 {
char *name;
unsigned long offset;
+ void (*decode_reg)(struct seq_file *s, u32 value);
};
struct debugfs_regset32 {