aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common
diff options
context:
space:
mode:
authorChen Baozi <baozich@gmail.com>2013-08-13 19:14:23 +0800
committerIan Campbell <ian.campbell@citrix.com>2013-08-22 13:17:29 +0100
commit282a1c2aba06d1860ed91e4df8dd4c42f1a822e6 (patch)
tree5be57581ea7420965162b04b13b2abcad17b5f81 /xen/common
parente7ac471d5ceb955c050c9330afd56d1cdb0da52f (diff)
downloadxen-282a1c2aba06d1860ed91e4df8dd4c42f1a822e6.tar.gz
xen-282a1c2aba06d1860ed91e4df8dd4c42f1a822e6.tar.bz2
xen-282a1c2aba06d1860ed91e4df8dd4c42f1a822e6.zip
xen: Introduce a helper to read a u32 property in device tree.
Signed-off-by: Chen Baozi <baozich@gmail.com> Acked-by: Julien Grall <julien.grall@linaro.org>
Diffstat (limited to 'xen/common')
-rw-r--r--xen/common/device_tree.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 84d704dc3d..12499853df 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -574,6 +574,21 @@ const void *dt_get_property(const struct dt_device_node *np,
return pp ? pp->value : NULL;
}
+bool_t dt_property_read_u32(const struct dt_device_node *np,
+ const char *name, u32 *out_value)
+{
+ u32 len;
+ const __be32 *val;
+
+ val = dt_get_property(np, name, &len);
+ if ( !val || len < sizeof(*out_value) )
+ return 0;
+
+ *out_value = be32_to_cpup(val);
+
+ return 1;
+}
+
bool_t dt_device_is_compatible(const struct dt_device_node *device,
const char *compat)
{