summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2011-08-01 00:25:20 -0500
committerKumar Gala <galak@kernel.crashing.org>2011-09-29 19:01:05 -0500
commit10aeabd18657edf6d65e45bd4c63a48cc794fef0 (patch)
treeffd9f9baa5b9664eefc92e0882109fb29275781f /common
parentf117c0f0731e99a5e468a300a71b34afa337e133 (diff)
downloadu-boot-imx-10aeabd18657edf6d65e45bd4c63a48cc794fef0.zip
u-boot-imx-10aeabd18657edf6d65e45bd4c63a48cc794fef0.tar.gz
u-boot-imx-10aeabd18657edf6d65e45bd4c63a48cc794fef0.tar.bz2
fdt: Add new fdt_create_phandle helper
Add a helper function that will return a phandle value for the given node. If the node doesn't have a phandle already one will be created. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Diffstat (limited to 'common')
-rw-r--r--common/fdt_support.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 8f7323d..46aa842 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1235,6 +1235,26 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle)
return ret;
}
+/*
+ * fdt_create_phandle: Create a phandle property for the given node
+ *
+ * @fdt: ptr to device tree
+ * @nodeoffset: node to update
+ */
+int fdt_create_phandle(void *fdt, int nodeoffset)
+{
+ /* see if there is a phandle already */
+ int phandle = fdt_get_phandle(fdt, nodeoffset);
+
+ /* if we got 0, means no phandle so create one */
+ if (phandle == 0) {
+ phandle = fdt_alloc_phandle(fdt);
+ fdt_set_phandle(fdt, nodeoffset, phandle);
+ }
+
+ return phandle;
+}
+
#if defined(CONFIG_VIDEO)
int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf)
{