diff mbox

[4/6,V2] FDT: Api to find compatible id for a given node

Message ID 1352884279-24067-5-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde Nov. 14, 2012, 9:11 a.m. UTC
This patch adds api to find compatible id for a given
FDT node

Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes in V2:
	- None
 include/fdtdec.h |   14 ++++++++++++++
 lib/fdtdec.c     |   12 ++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

Comments

Heiko Schocher Nov. 19, 2012, 8:54 a.m. UTC | #1
Hello Rajeshwari,

On 14.11.2012 10:11, Rajeshwari Shinde wrote:
> This patch adds api to find compatible id for a given
> FDT node
>
> Signed-off-by: Rajeshwari Shinde<rajeshwari.s@samsung.com>
> Acked-by: Simon Glass<sjg@chromium.org>
> ---
> Changes in V2:
> 	- None
>   include/fdtdec.h |   14 ++++++++++++++
>   lib/fdtdec.c     |   12 ++++++++++++
>   2 files changed, 26 insertions(+), 0 deletions(-)

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
diff mbox

Patch

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;
+}