diff mbox series

[1/7] debugfs: Extend debugfs regset to support register decoding

Message ID 20220629105135.2652773-2-kieran.bingham+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series renesas: vsp1: debugfs facility | expand

Commit Message

Kieran Bingham June 29, 2022, 10:51 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 950c63fa4d0b..b777d558ea0c 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -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;
 	}
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index c869f1e73d75..70dc487c03ed 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -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 {