diff mbox

[RFC,for-4.5,04/12] xen/dts: Add dt_property_read_bool

Message ID 1391794991-5919-5-git-send-email-julien.grall@linaro.org
State Accepted
Commit 16f9ccbe91986ec636d7edcc000ac7d18b0eae87
Headers show

Commit Message

Julien Grall Feb. 7, 2014, 5:43 p.m. UTC
The function check if property exists in a specific node.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/common/device_tree.c      |    6 ++----
 xen/include/xen/device_tree.h |   21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

Comments

Ian Campbell Feb. 19, 2014, 12:28 p.m. UTC | #1
On Fri, 2014-02-07 at 17:43 +0000, Julien Grall wrote:
> The function check if property exists in a specific node.

                       ^a 
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Julien Grall Feb. 19, 2014, 2:57 p.m. UTC | #2
Hi Ian,

On 02/19/2014 12:28 PM, Ian Campbell wrote:
> On Fri, 2014-02-07 at 17:43 +0000, Julien Grall wrote:
>> The function check if property exists in a specific node.
> 
>                        ^a 

I will fix it.

>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

Thanks,
diff mbox

Patch

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index c66d1d5..ccdb7ff 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -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;
 
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 9a8c3de..7c075d9 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -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
 
@@ -347,6 +348,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_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
  * @propname:   Name of the property to be searched