[kvm-unit-tests PATCH v2 1/2] devicetree: add /chosen/stdout-path support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/devicetree.c | 19 +++++++++++++++++++
 lib/devicetree.h |  9 +++++++++
 2 files changed, 28 insertions(+)

diff --git a/lib/devicetree.c b/lib/devicetree.c
index 0f9b4e9942736..36cb28610ff41 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -246,6 +246,25 @@ 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;
+	}
+
+	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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux