summaryrefslogtreecommitdiffstats
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-06-14 15:33:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-20 21:20:54 +0200
commit083995f8157b132646f79f0177063a33357f262c (patch)
treef583de4cd2dc0473fbb0581bcb4ec34a5f760fc7 /drivers/of/base.c
parent1d68e585321a945f1e5233416cce8f2a2fcc44cc (diff)
downloadbarebox-083995f8157b132646f79f0177063a33357f262c.tar.gz
barebox-083995f8157b132646f79f0177063a33357f262c.tar.xz
OF: base: import of_parse_phandle from Linux OF API
This imports of_parse_phandle from Linux OF API. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index b6d2b59165..309d236b36 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -839,6 +839,29 @@ int of_property_write_u32_array(struct device_node *np,
}
/**
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * @np: Pointer to device node holding phandle property
+ * @phandle_name: Name of property holding a phandle value
+ * @index: For properties holding a table of phandles, this is the index into
+ * the table
+ *
+ * Returns the device_node pointer found or NULL.
+ */
+struct device_node *of_parse_phandle(const struct device_node *np,
+ const char *phandle_name, int index)
+{
+ const __be32 *phandle;
+ int size;
+
+ phandle = of_get_property(np, phandle_name, &size);
+ if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
+ return NULL;
+
+ return of_find_node_by_phandle(be32_to_cpup(phandle + index));
+}
+EXPORT_SYMBOL(of_parse_phandle);
+
+/**
* of_parse_phandles_with_args - Find a node pointed by phandle in a list
* @np: pointer to a device tree node containing a list
* @list_name: property name that contains a list