summaryrefslogtreecommitdiff
path: root/common/fdt_support.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-10-23 00:05:47 -0500
committerAndrew Fleming-AFLEMING <afleming@freescale.com>2008-10-24 17:34:52 -0500
commit3bed2aaf2d50fd13273c14d17d4fd40ef42e0d0f (patch)
tree96ab5e57491f5aaacf45291f067aeb08f75937e6 /common/fdt_support.c
parent8ba93f68a1bae89e033527ce67b41b4a87aa5b7f (diff)
downloadu-boot-imx-3bed2aaf2d50fd13273c14d17d4fd40ef42e0d0f.zip
u-boot-imx-3bed2aaf2d50fd13273c14d17d4fd40ef42e0d0f.tar.gz
u-boot-imx-3bed2aaf2d50fd13273c14d17d4fd40ef42e0d0f.tar.bz2
fdt: Add fdt_getprop_u32_default helpers
Add helper functions to return find a node and return it's property or a default value. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Andrew Fleming-AFLEMING <afleming@freescale.com> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r--common/fdt_support.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 8ceeb0f..f430777 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -35,6 +35,33 @@
*/
DECLARE_GLOBAL_DATA_PTR;
+/**
+ * fdt_getprop_u32_default - Find a node and return it's property or a default
+ *
+ * @fdt: ptr to device tree
+ * @path: path of node
+ * @prop: property name
+ * @dflt: default value if the property isn't found
+ *
+ * Convenience function to find a node and return it's property or a
+ * default value if it doesn't exist.
+ */
+u32 fdt_getprop_u32_default(void *fdt, const char *path, const char *prop,
+ const u32 dflt)
+{
+ const u32 *val;
+ int off;
+
+ off = fdt_path_offset(fdt, path);
+ if (off < 0)
+ return dflt;
+
+ val = fdt_getprop(fdt, off, prop, NULL);
+ if (val)
+ return *val;
+ else
+ return dflt;
+}
/**
* fdt_find_and_setprop: Find a node and set it's property