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 1/7] vsprintf: support %pOF format specifier
Date: Mon,  9 Jan 2023 16:11:46 +0100	[thread overview]
Message-ID: <20230109151152.2052493-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230109151152.2052493-1-a.fatoum@pengutronix.de>

Supporting %pO* is easy enough and we have at least 50 instances in
tree, where this can be used.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/of.h   | 10 ++++++++++
 lib/vsprintf.c | 13 +++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/of.h b/include/of.h
index c69fa9605415..f22730c081fe 100644
--- a/include/of.h
+++ b/include/of.h
@@ -332,6 +332,11 @@ int of_autoenable_device_by_path(char *path);
 int of_autoenable_i2c_by_component(char *path);
 int of_prepend_machine_compatible(struct device_node *root, const char *compat);
 
+static inline const char *of_node_full_name(const struct device_node *np)
+{
+	return np ? np->full_name : "<no-node>";
+}
+
 #else
 static inline struct of_reserve_map *of_get_reserve_map(void)
 {
@@ -893,6 +898,11 @@ static inline int of_prepend_machine_compatible(struct device_node *root,
 	return -ENODEV;
 }
 
+static inline const char *of_node_full_name(const struct device_node *np)
+{
+	return "<no-node>";
+}
+
 #endif
 
 #define for_each_property_of_node(dn, pp) \
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 693f3c0cc0c8..1291cf7dd95f 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -19,6 +19,7 @@
 #include <malloc.h>
 #include <kallsyms.h>
 #include <wchar.h>
+#include <of.h>
 
 #include <common.h>
 #include <pbl.h>
@@ -391,6 +392,14 @@ char *address_val(char *buf, const char *end, const void *addr,
 	return number(buf, end, num, 16, field_width, precision, flags);
 }
 
+static noinline_for_stack
+char *device_node_string(char *buf, const char *end, const struct device_node *np,
+			 int field_width, int precision, int flags, const char *fmt)
+{
+	return string(buf, end, of_node_full_name(np), field_width,
+		      precision, flags);
+}
+
 /*
  * Show a '%p' thing.  A kernel extension is that the '%p' is followed
  * by an extra set of alphanumeric characters that are extended format
@@ -454,6 +463,10 @@ static char *pointer(const char *fmt, char *buf, const char *end, const void *pt
 		break;
 	case 'e':
 		return error_string(buf, end, ptr, field_width, precision, flags, fmt);
+	case 'O':
+		if (IS_ENABLED(CONFIG_OFTREE))
+			return device_node_string(buf, end, ptr, field_width, precision, flags, fmt + 1);
+		break;
 	case 'h':
 		if (IS_ENABLED(CONFIG_PRINTF_HEXSTR))
 			return hex_string(buf, end, ptr, field_width, precision, flags, fmt);
-- 
2.30.2




  reply	other threads:[~2023-01-09 15:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 15:11 [PATCH 0/7] treewide: misc helpers for porting Ahmad Fatoum
2023-01-09 15:11 ` Ahmad Fatoum [this message]
2023-01-09 15:11 ` [PATCH 2/7] include: driver: make dev_(get_priv|is_probed) argument const pointer Ahmad Fatoum
2023-01-09 15:11 ` [PATCH 3/7] include: sync io-64-nonatomic-*.h headers with Linux Ahmad Fatoum
2023-01-09 15:11 ` [PATCH 4/7] clk: add prepare/unprepare helpers Ahmad Fatoum
2023-01-09 15:11 ` [PATCH 5/7] of: provide of_node_get and of_node_put stubs Ahmad Fatoum
2023-01-09 15:11 ` [PATCH 6/7] include: linux/slab.h: define krealloc/kstrdup Ahmad Fatoum
2023-01-09 15:11 ` [PATCH 7/7] barebox-wrapper: define MODULE_DEVICE_TABLE Ahmad Fatoum
2023-01-10 15:00 ` [PATCH 0/7] treewide: misc helpers for porting 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=20230109151152.2052493-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