mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] lib: hexdump: make available for PBL debugging
Date: Wed, 19 Oct 2022 14:38:16 +0200	[thread overview]
Message-ID: <20221019123817.1659468-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221019123817.1659468-1-a.fatoum@pengutronix.de>

While we have puthexc_ll() for PBL use, for quick debugging or for
debug prints with PBL_CONSOLE enabled, print_hex_dump_bytes() can
come in handy. Build it for optional use in PBL as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/Makefile  |  2 +-
 lib/hexdump.c | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index 2308117fbdab..4717b8aec364 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -61,7 +61,7 @@ obj-y			+= wchar.o
 obj-y			+= libfile.o
 obj-y			+= bitmap.o
 obj-y			+= gcd.o
-obj-y			+= hexdump.o
+obj-pbl-y		+= hexdump.o
 obj-$(CONFIG_FONTS)	+= fonts/
 obj-$(CONFIG_BAREBOX_LOGO)     += logo/
 obj-y			+= reed_solomon/
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 033e1d28d171..a71474a55348 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -10,6 +10,7 @@
 #include <linux/log2.h>
 #include <linux/printk.h>
 #include <asm/unaligned.h>
+#include <pbl.h>
 
 const char hex_asc[] = "0123456789abcdef";
 EXPORT_SYMBOL(hex_asc);
@@ -243,9 +244,13 @@ void dev_print_hex_dump(struct device_d *dev, const char *level,
 	const u8 *ptr = buf;
 	int i, linelen, remaining = len;
 	unsigned char linebuf[32 * 3 + 2 + 32 + 1];
-	char *name;
+	char *name = "";
 
-	name = basprintf("%s%s", dev ? dev_name(dev) : "", dev ? ": " : "");
+	if (IN_PBL)
+		dev = NULL;
+
+	if (dev)
+		name = basprintf("%s: ", dev_name(dev));
 
 	if (rowsize != 16 && rowsize != 32)
 		rowsize = 16;
@@ -273,6 +278,7 @@ void dev_print_hex_dump(struct device_d *dev, const char *level,
 		}
 	}
 
-	free(name);
+	if (dev)
+		free(name);
 }
 EXPORT_SYMBOL(dev_print_hex_dump);
-- 
2.30.2




  reply	other threads:[~2022-10-19 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 12:38 [PATCH 1/3] include: debug_ll: define puthexc_ll Ahmad Fatoum
2022-10-19 12:38 ` Ahmad Fatoum [this message]
2022-10-19 12:38 ` [PATCH 3/3] pbl: decomp: print mismatched hashes on one line each Ahmad Fatoum
2022-11-02  8:26 ` [PATCH 1/3] include: debug_ll: define puthexc_ll Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221019123817.1659468-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox