\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
* 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
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
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
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
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
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
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
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
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