diff mbox series

[2/2] dm: dump.c: Refactor dm_dump_drivers prints

Message ID 20200405164741.11243-2-ovpanait@gmail.com
State Accepted
Commit 28888ca38ecc1c427d41db92c624cbf6d343df74
Headers show
Series [1/2] dm: dump.c: Fix segfault when entry->of_match is NULL | expand

Commit Message

Ovidiu Panait April 5, 2020, 4:47 p.m. UTC
Refactor the printing sequence in dm_dump_drivers to make it more clear.

Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
Cc: Sean Anderson <seanga2 at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
---
 drivers/core/dump.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Simon Glass April 6, 2020, 3:42 a.m. UTC | #1
On Sun, 5 Apr 2020 at 10:47, Ovidiu Panait <ovpanait at gmail.com> wrote:
>
> Refactor the printing sequence in dm_dump_drivers to make it more clear.
>
> Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
> Cc: Sean Anderson <seanga2 at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
>  drivers/core/dump.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
>

Reviewed-by: Simon Glass <sjg at chromium.org>
Simon Glass April 9, 2020, 9:23 p.m. UTC | #2
On Sun, 5 Apr 2020 at 10:47, Ovidiu Panait <ovpanait at gmail.com> wrote:
>
> Refactor the printing sequence in dm_dump_drivers to make it more clear.
>
> Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
> Cc: Sean Anderson <seanga2 at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
>  drivers/core/dump.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
>

Reviewed-by: Simon Glass <sjg at chromium.org>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index b5046398d4..cb8a25b9ad 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -107,12 +107,16 @@  void dm_dump_drivers(void)
 	puts("Driver                Compatible\n");
 	puts("--------------------------------\n");
 	for (entry = d; entry < d + n_ents; entry++) {
-		for (match = entry->of_match;
-		     match && match->compatible; match++)
-			printf("%-20.20s  %s\n",
-			       match == entry->of_match ? entry->name : "",
-			       match->compatible);
-		if (match == entry->of_match)
-			printf("%-20.20s\n", entry->name);
+		match = entry->of_match;
+
+		printf("%-20.20s", entry->name);
+		if (match) {
+			printf("  %s", match->compatible);
+			match++;
+		}
+		printf("\n");
+
+		for (; match && match->compatible; match++)
+			printf("%-20.20s  %s\n", "", match->compatible);
 	}
 }