[U-Boot] [PATCH 4/6] FDT: Api to find compatible id for a given node

Rajeshwari Shinde rajeshwari.s at samsung.com
Thu Nov 8 06:30:01 CET 2012


This patch adds api to find compatible id for a given
FDT node

Signed-off-by: Rajeshwari Shinde <rajeshwari.s at samsung.com>
---
 include/fdtdec.h |   14 ++++++++++++++
 lib/fdtdec.c     |   12 ++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index f9aac31..d501d7e 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -389,4 +389,18 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
  */
 const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 			     const char *prop_name, int count);
+
+/**
+ * Find the compatible ID for a given node.
+ *
+ * Generally each node has at least one compatible string attached to it.
+ * This function looks through our list of known compatible strings and
+ * returns the corresponding ID which matches the compatible string.
+ *
+ * @param blob          FDT blob to use
+ * @param node          Node containing compatible string to find
+ * @return compatible ID, or COMPAT_UNKNOWN if we cannot find a match
+ */
+enum fdt_compat_id fdtdec_lookup(const void *blob, int node);
+
 #endif
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 6e8c24c..dbfca1a 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -516,3 +516,15 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 		return NULL;
 	return cell;
 }
+
+enum fdt_compat_id fdtdec_lookup(const void *blob, int node)
+{
+	enum fdt_compat_id id;
+
+	/* Search our drivers */
+	for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
+		if (0 == fdt_node_check_compatible(blob, node,
+				compat_names[id]))
+			return id;
+	return COMPAT_UNKNOWN;
+}
-- 
1.7.4.4



More information about the U-Boot mailing list