[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH RFCv4 16/35] plat/ofw: Add fdt_prop_read_bool



This fdt_prop_read_bool helper returns true when the property is
existed. This is helpful when we just need to know whether the property
is there instead of getting its value.

Signed-off-by: Jia He <justin.he@xxxxxxx>
---
 plat/drivers/include/ofw/fdt.h | 14 ++++++++++++++
 plat/drivers/ofw/fdt.c         |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index 0220fad..a3896ff 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -35,6 +35,8 @@
 #ifndef _PLAT_DRIVER_OFW_FDT_H
 #define _PLAT_DRIVER_OFW_FDT_H
 
+#include <stdbool.h>
+
 #define FDT_BAD_ADDR (uint64_t)(-1)
 
 /**
@@ -186,4 +188,16 @@ int fdt_node_offset_idx_by_compatible_list(const void 
*fdt, int startoffset,
  */
 int fdt_get_interrupt(const void *fdt, int nodeoffset,
                                uint32_t index, int *size, fdt32_t **prop);
+
+/**
+ * fdt_prop_read_bool - Find a property
+ * @fdt: pointer to the device tree blob
+ * @start_offset: start offset of the node to find the address for
+ * @propname:  name of the property to be searched.
+ *
+ * Search for a property in a device node.
+ * Returns true if the property exists false otherwise.
+ */
+bool fdt_prop_read_bool(const void *fdt, int start_offset,
+                                        const char *propname);
 #endif
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 876637d..48c5dfd 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -337,3 +337,11 @@ int fdt_get_interrupt(const void *fdt, int nodeoffset,
 
        return 0;
 }
+
+bool fdt_prop_read_bool(const void *fdt, int start_offset,
+                                        const char *propname)
+{
+       const struct fdt_property *prop = fdt_getprop(fdt, start_offset, 
propname, NULL);
+
+       return prop ? true : false;
+}
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.