From 9bbb08bce967c599127bb0548a097e87ebfe228e Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 9 Jan 2023 16:11:46 +0100 Subject: 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 Link: https://lore.barebox.org/20230109151152.2052493-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- lib/vsprintf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.1