[Skiboot] [PATCH 11/33] devicetree: Add dt_node_is_enabled()

Benjamin Herrenschmidt benh at kernel.crashing.org
Sat Jun 25 08:47:34 AEST 2016


This accessor tests the "status" property allowing us to represent
disabled devices in the device-tree. It will be used by PHB4 initially
but its usage could be made more widespread.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 core/device.c    | 10 ++++++++++
 include/device.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/core/device.c b/core/device.c
index 4818d40..9e7ef0d 100644
--- a/core/device.c
+++ b/core/device.c
@@ -910,3 +910,13 @@ u64 dt_translate_address(const struct dt_node *node, unsigned int index,
 	/* XXX TODO */
 	return dt_get_address(node, index, out_size);
 }
+
+bool dt_node_is_enabled(struct dt_node *node)
+{
+	const struct dt_property *p = dt_find_property(node, "status");
+
+	if (!p)
+		return true;
+
+	return p->len > 1 && p->prop[0] == 'o' && p->prop[1] == 'k';
+}
diff --git a/include/device.h b/include/device.h
index 28dbd5d..ed4fc46 100644
--- a/include/device.h
+++ b/include/device.h
@@ -161,6 +161,8 @@ struct dt_node *dt_find_compatible_node_on_chip(struct dt_node *root,
 	for (node = NULL; 			        \
 	     (node = dt_find_compatible_node_on_chip(root, node,\
 						     compat, chip_id)) != NULL;)
+/* Check status property */
+bool dt_node_is_enabled(struct dt_node *node);
 
 /* Build the full path for a node. Return a new block of memory, caller
  * shall free() it
-- 
2.7.4



More information about the Skiboot mailing list