diff mbox series

[v4.1,18/21] media: rkisp1: debug: Update max register name length

Message ID 20220425210104.31964-1-laurent.pinchart@ideasonboard.com (mailing list archive)
State New
Headers show
Series None | expand

Commit Message

Laurent Pinchart April 25, 2022, 9:01 p.m. UTC
Update the maximum register name length to match all the registers being
printed. This helps getting a consistent alignment of register dumps
when concatenating multiple debugfs files.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v4:

- Replace dynamic per-file register length with global maximum length
---
 .../media/platform/rockchip/rkisp1/rkisp1-debug.c    | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Ricardo Ribalda April 26, 2022, 7:39 a.m. UTC | #1
Hi Laurent

Thanks for the change


On Mon, 25 Apr 2022 at 23:01, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Update the maximum register name length to match all the registers being
> printed. This helps getting a consistent alignment of register dumps
> when concatenating multiple debugfs files.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> Changes since v4:
>
> - Replace dynamic per-file register length with global maximum length
> ---
>  .../media/platform/rockchip/rkisp1/rkisp1-debug.c    | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> index 2c226f20f525..e76dc2b164b6 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> @@ -11,8 +11,10 @@
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
>  #include <linux/device.h>
> +#include <linux/minmax.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/seq_file.h>
> +#include <linux/string.h>
>
>  #include "rkisp1-common.h"
>  #include "rkisp1-regs.h"
> @@ -28,10 +30,14 @@ struct rkisp1_debug_register {
>         RKISP1_CIF_##name, RKISP1_CIF_##name##_SHD, #name \
>  }
>
> +/* Keep this up-to-date when adding new registers. */
> +#define RKISP1_MAX_REG_LENGTH          21
> +
>  static int rkisp1_debug_dump_regs(struct rkisp1_device *rkisp1,
>                                   struct seq_file *m, unsigned int offset,
>                                   const struct rkisp1_debug_register *regs)
>  {
> +       const int width = RKISP1_MAX_REG_LENGTH;
>         u32 val, shd;
>         int ret;
>
> @@ -39,15 +45,15 @@ static int rkisp1_debug_dump_regs(struct rkisp1_device *rkisp1,
>         if (ret <= 0)
>                 return ret ? : -ENODATA;
>
> -       for ( ; regs->name; ++regs) {
> +       for (; regs->name; ++regs) {
>                 val = rkisp1_read(rkisp1, offset + regs->reg);
>
>                 if (regs->shd) {
>                         shd = rkisp1_read(rkisp1, offset + regs->shd);
> -                       seq_printf(m, "%14s: 0x%08x/0x%08x\n", regs->name,
> +                       seq_printf(m, "%*s: 0x%08x/0x%08x\n", width, regs->name,
>                                    val, shd);
>                 } else {
> -                       seq_printf(m, "%14s: 0x%08x\n", regs->name, val);
> +                       seq_printf(m, "%*s: 0x%08x\n", width, regs->name, val);
>                 }
>         }
>
> --
> Regards,
>
> Laurent Pinchart
>
diff mbox series

Patch

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
index 2c226f20f525..e76dc2b164b6 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
@@ -11,8 +11,10 @@ 
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/minmax.h>
 #include <linux/pm_runtime.h>
 #include <linux/seq_file.h>
+#include <linux/string.h>
 
 #include "rkisp1-common.h"
 #include "rkisp1-regs.h"
@@ -28,10 +30,14 @@  struct rkisp1_debug_register {
 	RKISP1_CIF_##name, RKISP1_CIF_##name##_SHD, #name \
 }
 
+/* Keep this up-to-date when adding new registers. */
+#define RKISP1_MAX_REG_LENGTH		21
+
 static int rkisp1_debug_dump_regs(struct rkisp1_device *rkisp1,
 				  struct seq_file *m, unsigned int offset,
 				  const struct rkisp1_debug_register *regs)
 {
+	const int width = RKISP1_MAX_REG_LENGTH;
 	u32 val, shd;
 	int ret;
 
@@ -39,15 +45,15 @@  static int rkisp1_debug_dump_regs(struct rkisp1_device *rkisp1,
 	if (ret <= 0)
 		return ret ? : -ENODATA;
 
-	for ( ; regs->name; ++regs) {
+	for (; regs->name; ++regs) {
 		val = rkisp1_read(rkisp1, offset + regs->reg);
 
 		if (regs->shd) {
 			shd = rkisp1_read(rkisp1, offset + regs->shd);
-			seq_printf(m, "%14s: 0x%08x/0x%08x\n", regs->name,
+			seq_printf(m, "%*s: 0x%08x/0x%08x\n", width, regs->name,
 				   val, shd);
 		} else {
-			seq_printf(m, "%14s: 0x%08x\n", regs->name, val);
+			seq_printf(m, "%*s: 0x%08x\n", width, regs->name, val);
 		}
 	}