xen/dts: Add dt_property_read_bool
authorJulien Grall <julien.grall@linaro.org>
Tue, 22 Apr 2014 13:14:23 +0000 (14:14 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 2 May 2014 12:34:33 +0000 (13:34 +0100)
The function check if a property exists in a specific node.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/common/device_tree.c
xen/include/xen/device_tree.h

index 74425ab534e8f4e8266681bbe146f9fc75f8ee22..016aecfa36e33a5aac5ecf877ab8df419755181c 100644 (file)
@@ -512,10 +512,8 @@ static void __init *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
 }
 
 /* Find a property with a given name for a given node and return it. */
-static const struct dt_property *
-dt_find_property(const struct dt_device_node *np,
-                 const char *name,
-                 u32 *lenp)
+const struct dt_property *dt_find_property(const struct dt_device_node *np,
+                                           const char *name, u32 *lenp)
 {
     const struct dt_property *pp;
 
index 76faf11c55a29a1e5c03065c2291d2f7b28c2e18..9c396ee1bb46e0eb0276fc557c8c455344c13546 100644 (file)
@@ -15,6 +15,7 @@
 #include <xen/init.h>
 #include <xen/string.h>
 #include <xen/types.h>
+#include <xen/stdbool.h>
 
 #define DEVICE_TREE_MAX_DEPTH 16
 
@@ -348,6 +349,10 @@ struct dt_device_node *dt_find_compatible_node(struct dt_device_node *from,
 const void *dt_get_property(const struct dt_device_node *np,
                             const char *name, u32 *lenp);
 
+const struct dt_property *dt_find_property(const struct dt_device_node *np,
+                                           const char *name, u32 *lenp);
+
+
 /**
  * dt_property_read_u32 - Helper to read a u32 property.
  * @np: node to get the value
@@ -369,6 +374,22 @@ bool_t dt_property_read_u32(const struct dt_device_node *np,
 bool_t dt_property_read_u64(const struct dt_device_node *np,
                             const char *name, u64 *out_value);
 
+/**
+ * dt_property_read_bool - Check if a property exists
+ * @np: node to get the value
+ * @name: name of the property
+ *
+ * Search for a property in a device node.
+ * Return true if the property exists false otherwise.
+ */
+static inline bool_t dt_property_read_bool(const struct dt_device_node *np,
+                                           const char *name)
+{
+    const struct dt_property *prop = dt_find_property(np, name, NULL);
+
+    return prop ? true : false;
+}
+
 /**
  * dt_property_read_string - Find and read a string from a property
  * @np:         Device node from which the property value is to be read