summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-19 14:38:16 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-11-02 09:26:08 +0100
commit24f81261a7b82cc47cae7457c56422cc8f1c7837 (patch)
tree8663ddc66618ca6e13b0f07063fc55de91aa280c /lib
parentef617bbfe348b0e7e45a682cdb733107fedf0ca1 (diff)
downloadbarebox-24f81261a7b82cc47cae7457c56422cc8f1c7837.tar.gz
barebox-24f81261a7b82cc47cae7457c56422cc8f1c7837.tar.xz
lib: hexdump: make available for PBL debugging
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> Link: https://lore.barebox.org/20221019123817.1659468-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/hexdump.c12
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 3f6653d74e..21afb233fa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -60,7 +60,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 033e1d28d1..a71474a553 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);