Signed-off-by: Andrew Jones <drjo...@redhat.com> --- lib/devicetree.c | 24 ++++++++++++++++++++++++ lib/devicetree.h | 9 +++++++++ 2 files changed, 33 insertions(+)
diff --git a/lib/devicetree.c b/lib/devicetree.c index 0f9b4e9942736..93f3841daf22c 100644 --- a/lib/devicetree.c +++ b/lib/devicetree.c @@ -246,6 +246,30 @@ int dt_get_bootargs(const char **bootargs) return 0; } +int dt_get_default_console_node(void) +{ + const struct fdt_property *prop; + int node, len; + + node = fdt_path_offset(fdt, "/chosen"); + if (node < 0) + return node; + + prop = fdt_get_property(fdt, node, "stdout-path", &len); + if (!prop) { + prop = fdt_get_property(fdt, node, "linux,stdout-path", &len); + if (!prop) + return len; + } + + if (len == 0) { + /* When it's useless pretend we didn't find it. */ + return -FDT_ERR_NOTFOUND; + } + + return fdt_path_offset(fdt, prop->data); +} + int dt_init(const void *fdt_ptr) { struct dt_bus *defbus = (struct dt_bus *)&dt_default_bus; diff --git a/lib/devicetree.h b/lib/devicetree.h index 7fddc2464de8a..c8c86eeae28b6 100644 --- a/lib/devicetree.h +++ b/lib/devicetree.h @@ -215,6 +215,15 @@ extern int dt_get_reg(int fdtnode, int regidx, struct dt_reg *reg); extern int dt_get_bootargs(const char **bootargs); /* + * dt_get_default_console_node gets the node of the path stored in + * /chosen/stdout-path (or the deprecated /chosen/linux,stdout-path) + * returns + * - the node (>= 0) on success + * - a negative FDT_ERR_* value on failure + */ +extern int dt_get_default_console_node(void); + +/* * dt_get_memory_params gets the memory parameters from the /memory node(s) * storing each memory region ("address size" tuple) in consecutive entries * of @regs, up to @nr_regs -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html