[Skiboot] [RFC PATCH 2/2] EXAMPLE: Print full DT path when adding a node
Oliver O'Halloran
oohall at gmail.com
Fri Oct 6 16:30:29 AEDT 2017
An example of how to use the custom printf specifiers. In this case it
will print out the full node path when adding a node to
the device-tree, like so:
[ 0.001493894,3] Added /ibm,opal to tree
[ 0.001504982,3] Added /ibm,opal/event to tree
[ 0.001512892,3] Added /ibm,opal/firmware to tree
[ 0.001521920,3] Added /ibm,opal/firmware/exports to tree
[ 0.001535936,3] Added /ibm,opal/power-mgt to tree
Not-signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
core/device.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/core/device.c b/core/device.c
index fc1db5689a73..44463a9398a5 100644
--- a/core/device.c
+++ b/core/device.c
@@ -153,6 +153,8 @@ struct dt_node *dt_new(struct dt_node *parent, const char *name)
dt_destroy(new);
return NULL;
}
+
+ prerror("Added %pD to tree\n", new);
return new;
}
@@ -1107,3 +1109,24 @@ void dt_adjust_subtree_phandle(struct dt_node *dev,
set_last_phandle(max_phandle);
}
+
+static int print_dt_node_path(char **buffer, size_t bufsize, const void *value)
+{
+ char *path = dt_get_path(value);
+ char *into = *buffer;
+ int i;
+
+ for (i = 0; path[i] && i < bufsize; i++)
+ into[i] = path[i];
+
+ *buffer += i;
+ free(path);
+
+ /* return the number of characters added to the buffer */
+ return i;
+}
+
+DECLARE_PRINTFMT(dt_node_path) = {
+ .specifier = "D",
+ .func = &print_dt_node_path,
+};
--
2.9.5
More information about the Skiboot
mailing list