diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-01-09 16:11:46 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-01-10 15:59:54 +0100 |
commit | 9bbb08bce967c599127bb0548a097e87ebfe228e (patch) | |
tree | 0b9562f5f88e472ed2c9445dce02b7dc3d21de65 | |
parent | 23c644d306d9f4b7b4a85c50b08363ff452dfe91 (diff) | |
download | barebox-9bbb08bce967c599127bb0548a097e87ebfe228e.tar.gz |
vsprintf: support %pOF format specifier
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>
Link: https://lore.barebox.org/20230109151152.2052493-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | include/of.h | 10 | ||||
-rw-r--r-- | lib/vsprintf.c | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/of.h b/include/of.h index c69fa96054..f22730c081 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 693f3c0cc0..1291cf7dd9 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); |