]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Include/libfdt.h
EmbeddedPkg/FdtLib: Updated libfdt to 1.4.0
[mirror_edk2.git] / EmbeddedPkg / Include / libfdt.h
index 85fe324c4d9eaeff87a88a2dc6d895b631f25263..212cb995dfb30d366251285740f60f977111543c 100644 (file)
@@ -136,6 +136,28 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
 \r
 int fdt_next_node(const void *fdt, int offset, int *depth);\r
 \r
+/**\r
+ * fdt_first_subnode() - get offset of first direct subnode\r
+ *\r
+ * @fdt:       FDT blob\r
+ * @offset:    Offset of node to check\r
+ * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none\r
+ */\r
+int fdt_first_subnode(const void *fdt, int offset);\r
+\r
+/**\r
+ * fdt_next_subnode() - get offset of next direct subnode\r
+ *\r
+ * After first calling fdt_first_subnode(), call this function repeatedly to\r
+ * get direct subnodes of a parent node.\r
+ *\r
+ * @fdt:       FDT blob\r
+ * @offset:    Offset of previous subnode\r
+ * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more\r
+ * subnodes\r
+ */\r
+int fdt_next_subnode(const void *fdt, int offset);\r
+\r
 /**********************************************************************/\r
 /* General functions                                                  */\r
 /**********************************************************************/\r
@@ -582,7 +604,7 @@ const char *fdt_get_alias_namelen(const void *fdt,
  * value of the property named 'name' in the node /aliases.\r
  *\r
  * returns:\r
- *     a pointer to the expansion of the alias named 'name', of it exists\r
+ *     a pointer to the expansion of the alias named 'name', if it exists\r
  *     NULL, if the given alias or the /aliases node does not exist\r
  */\r
 const char *fdt_get_alias(const void *fdt, const char *name);\r
@@ -816,6 +838,20 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
 int fdt_node_offset_by_compatible(const void *fdt, int startoffset,\r
                                  const char *compatible);\r
 \r
+/**\r
+ * fdt_stringlist_contains - check a string list property for a string\r
+ * @strlist: Property containing a list of strings to check\r
+ * @listlen: Length of property\r
+ * @str: String to search for\r
+ *\r
+ * This is a utility function provided for convenience. The list contains\r
+ * one or more strings, each terminated by \0, as is found in a device tree\r
+ * "compatible" property.\r
+ *\r
+ * @return: 1 if the string is found in the list, 0 not found, or invalid list\r
+ */\r
+int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);\r
+\r
 /**********************************************************************/\r
 /* Write-in-place functions                                           */\r
 /**********************************************************************/\r
@@ -882,8 +918,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,\r
                                          const char *name, uint32_t val)\r
 {\r
-       val = cpu_to_fdt32(val);\r
-       return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt32_t tmp = cpu_to_fdt32(val);\r
+       return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r
@@ -917,8 +953,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,\r
                                          const char *name, uint64_t val)\r
 {\r
-       val = cpu_to_fdt64(val);\r
-       return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt64_t tmp = cpu_to_fdt64(val);\r
+       return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r
@@ -993,13 +1029,13 @@ int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);\r
 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)\r
 {\r
-       val = cpu_to_fdt32(val);\r
-       return fdt_property(fdt, name, &val, sizeof(val));\r
+       fdt32_t tmp = cpu_to_fdt32(val);\r
+       return fdt_property(fdt, name, &tmp, sizeof(tmp));\r
 }\r
 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)\r
 {\r
-       val = cpu_to_fdt64(val);\r
-       return fdt_property(fdt, name, &val, sizeof(val));\r
+       fdt64_t tmp = cpu_to_fdt64(val);\r
+       return fdt_property(fdt, name, &tmp, sizeof(tmp));\r
 }\r
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)\r
 {\r
@@ -1154,8 +1190,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,\r
                                  uint32_t val)\r
 {\r
-       val = cpu_to_fdt32(val);\r
-       return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt32_t tmp = cpu_to_fdt32(val);\r
+       return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r
@@ -1189,8 +1225,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,\r
                                  uint64_t val)\r
 {\r
-       val = cpu_to_fdt64(val);\r
-       return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt64_t tmp = cpu_to_fdt64(val);\r
+       return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r
@@ -1296,8 +1332,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,\r
                                     const char *name, uint32_t val)\r
 {\r
-       val = cpu_to_fdt32(val);\r
-       return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt32_t tmp = cpu_to_fdt32(val);\r
+       return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r
@@ -1331,8 +1367,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,\r
                                     const char *name, uint64_t val)\r
 {\r
-       val = cpu_to_fdt64(val);\r
-       return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));\r
+       fdt64_t tmp = cpu_to_fdt64(val);\r
+       return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\r
 }\r
 \r
 /**\r