#ifndef _LIBFDT_H\r
#define _LIBFDT_H\r
+\r
/*\r
* libfdt - Flat Device Tree manipulation\r
* Copyright (C) 2006 David Gibson, IBM Corporation.\r
#include <libfdt_env.h>\r
#include <fdt.h>\r
\r
-#define FDT_FIRST_SUPPORTED_VERSION 0x10\r
-#define FDT_LAST_SUPPORTED_VERSION 0x11\r
+#define FDT_FIRST_SUPPORTED_VERSION 0x10\r
+#define FDT_LAST_SUPPORTED_VERSION 0x11\r
\r
/* Error codes: informative error codes */\r
-#define FDT_ERR_NOTFOUND 1\r
- /* FDT_ERR_NOTFOUND: The requested node or property does not exist */\r
-#define FDT_ERR_EXISTS 2\r
- /* FDT_ERR_EXISTS: Attemped to create a node or property which\r
- * already exists */\r
-#define FDT_ERR_NOSPACE 3\r
- /* FDT_ERR_NOSPACE: Operation needed to expand the device\r
- * tree, but its buffer did not have sufficient space to\r
- * contain the expanded tree. Use fdt_open_into() to move the\r
- * device tree to a buffer with more space. */\r
+#define FDT_ERR_NOTFOUND 1\r
+/* FDT_ERR_NOTFOUND: The requested node or property does not exist */\r
+#define FDT_ERR_EXISTS 2\r
+\r
+/* FDT_ERR_EXISTS: Attempted to create a node or property which\r
+ * already exists */\r
+#define FDT_ERR_NOSPACE 3\r
+\r
+/* FDT_ERR_NOSPACE: Operation needed to expand the device\r
+ * tree, but its buffer did not have sufficient space to\r
+ * contain the expanded tree. Use fdt_open_into() to move the\r
+ * device tree to a buffer with more space. */\r
\r
/* Error codes: codes for bad parameters */\r
-#define FDT_ERR_BADOFFSET 4\r
- /* FDT_ERR_BADOFFSET: Function was passed a structure block\r
- * offset which is out-of-bounds, or which points to an\r
- * unsuitable part of the structure for the operation. */\r
-#define FDT_ERR_BADPATH 5\r
- /* FDT_ERR_BADPATH: Function was passed a badly formatted path\r
- * (e.g. missing a leading / for a function which requires an\r
- * absolute path) */\r
-#define FDT_ERR_BADPHANDLE 6\r
- /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle\r
- * value. phandle values of 0 and -1 are not permitted. */\r
-#define FDT_ERR_BADSTATE 7\r
- /* FDT_ERR_BADSTATE: Function was passed an incomplete device\r
- * tree created by the sequential-write functions, which is\r
- * not sufficiently complete for the requested operation. */\r
+#define FDT_ERR_BADOFFSET 4\r
+\r
+/* FDT_ERR_BADOFFSET: Function was passed a structure block\r
+ * offset which is out-of-bounds, or which points to an\r
+ * unsuitable part of the structure for the operation. */\r
+#define FDT_ERR_BADPATH 5\r
+\r
+/* FDT_ERR_BADPATH: Function was passed a badly formatted path\r
+ * (e.g. missing a leading / for a function which requires an\r
+ * absolute path) */\r
+#define FDT_ERR_BADPHANDLE 6\r
+\r
+/* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.\r
+ * This can be caused either by an invalid phandle property\r
+ * length, or the phandle value was either 0 or -1, which are\r
+ * not permitted. */\r
+#define FDT_ERR_BADSTATE 7\r
+\r
+/* FDT_ERR_BADSTATE: Function was passed an incomplete device\r
+ * tree created by the sequential-write functions, which is\r
+ * not sufficiently complete for the requested operation. */\r
\r
/* Error codes: codes for bad device tree blobs */\r
-#define FDT_ERR_TRUNCATED 8\r
- /* FDT_ERR_TRUNCATED: Structure block of the given device tree\r
- * ends without an FDT_END tag. */\r
-#define FDT_ERR_BADMAGIC 9\r
- /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a\r
- * device tree at all - it is missing the flattened device\r
- * tree magic number. */\r
-#define FDT_ERR_BADVERSION 10\r
- /* FDT_ERR_BADVERSION: Given device tree has a version which\r
- * can't be handled by the requested operation. For\r
- * read-write functions, this may mean that fdt_open_into() is\r
- * required to convert the tree to the expected version. */\r
-#define FDT_ERR_BADSTRUCTURE 11\r
- /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt\r
- * structure block or other serious error (e.g. misnested\r
- * nodes, or subnodes preceding properties). */\r
-#define FDT_ERR_BADLAYOUT 12\r
- /* FDT_ERR_BADLAYOUT: For read-write functions, the given\r
- * device tree has it's sub-blocks in an order that the\r
- * function can't handle (memory reserve map, then structure,\r
- * then strings). Use fdt_open_into() to reorganize the tree\r
- * into a form suitable for the read-write operations. */\r
+#define FDT_ERR_TRUNCATED 8\r
+\r
+/* FDT_ERR_TRUNCATED: Structure block of the given device tree\r
+ * ends without an FDT_END tag. */\r
+#define FDT_ERR_BADMAGIC 9\r
+\r
+/* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a\r
+ * device tree at all - it is missing the flattened device\r
+ * tree magic number. */\r
+#define FDT_ERR_BADVERSION 10\r
+\r
+/* FDT_ERR_BADVERSION: Given device tree has a version which\r
+ * can't be handled by the requested operation. For\r
+ * read-write functions, this may mean that fdt_open_into() is\r
+ * required to convert the tree to the expected version. */\r
+#define FDT_ERR_BADSTRUCTURE 11\r
+\r
+/* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt\r
+ * structure block or other serious error (e.g. misnested\r
+ * nodes, or subnodes preceding properties). */\r
+#define FDT_ERR_BADLAYOUT 12\r
+\r
+/* FDT_ERR_BADLAYOUT: For read-write functions, the given\r
+ * device tree has it's sub-blocks in an order that the\r
+ * function can't handle (memory reserve map, then structure,\r
+ * then strings). Use fdt_open_into() to reorganize the tree\r
+ * into a form suitable for the read-write operations. */\r
\r
/* "Can't happen" error indicating a bug in libfdt */\r
-#define FDT_ERR_INTERNAL 13\r
- /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.\r
- * Should never be returned, if it is, it indicates a bug in\r
- * libfdt itself. */\r
+#define FDT_ERR_INTERNAL 13\r
+\r
+/* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.\r
+ * Should never be returned, if it is, it indicates a bug in\r
+ * libfdt itself. */\r
+\r
+/* Errors in device tree content */\r
+#define FDT_ERR_BADNCELLS 14\r
+\r
+/* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells\r
+ * or similar property with a bad format or value */\r
+\r
+#define FDT_ERR_BADVALUE 15\r
+\r
+/* FDT_ERR_BADVALUE: Device tree has a property with an unexpected\r
+ * value. For example: a property expected to contain a string list\r
+ * is not NUL-terminated within the length of its value. */\r
+\r
+#define FDT_ERR_BADOVERLAY 16\r
+\r
+/* FDT_ERR_BADOVERLAY: The device tree overlay, while\r
+ * correctly structured, cannot be applied due to some\r
+ * unexpected or missing value, property or node. */\r
\r
-#define FDT_ERR_MAX 13\r
+#define FDT_ERR_NOPHANDLES 17\r
+\r
+/* FDT_ERR_NOPHANDLES: The device tree doesn't have any\r
+ * phandle available anymore without causing an overflow */\r
+\r
+#define FDT_ERR_MAX 17\r
\r
/**********************************************************************/\r
/* Low-level functions (you probably don't need these) */\r
/**********************************************************************/\r
\r
-const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);\r
-static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)\r
+#ifndef SWIG /* This function is not useful in Python */\r
+const void *\r
+fdt_offset_ptr (\r
+ const void *fdt,\r
+ int offset,\r
+ unsigned int checklen\r
+ );\r
+\r
+#endif\r
+static inline void *\r
+fdt_offset_ptr_w (\r
+ void *fdt,\r
+ int offset,\r
+ int checklen\r
+ )\r
{\r
- return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);\r
+ return (void *)(uintptr_t)fdt_offset_ptr (fdt, offset, checklen);\r
}\r
\r
-uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);\r
+uint32_t\r
+fdt_next_tag (\r
+ const void *fdt,\r
+ int offset,\r
+ int *nextoffset\r
+ );\r
\r
/**********************************************************************/\r
/* Traversal functions */\r
/**********************************************************************/\r
\r
-int fdt_next_node(const void *fdt, int offset, int *depth);\r
+int\r
+fdt_next_node (\r
+ const void *fdt,\r
+ int offset,\r
+ int *depth\r
+ );\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\r
+fdt_first_subnode (\r
+ const void *fdt,\r
+ int offset\r
+ );\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\r
+fdt_next_subnode (\r
+ const void *fdt,\r
+ int offset\r
+ );\r
+\r
+/**\r
+ * fdt_for_each_subnode - iterate over all subnodes of a parent\r
+ *\r
+ * @node: child node (int, lvalue)\r
+ * @fdt: FDT blob (const void *)\r
+ * @parent: parent node (int)\r
+ *\r
+ * This is actually a wrapper around a for loop and would be used like so:\r
+ *\r
+ * fdt_for_each_subnode(node, fdt, parent) {\r
+ * Use node\r
+ * ...\r
+ * }\r
+ *\r
+ * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {\r
+ * Error handling\r
+ * }\r
+ *\r
+ * Note that this is implemented as a macro and @node is used as\r
+ * iterator in the loop. The parent variable be constant or even a\r
+ * literal.\r
+ *\r
+ */\r
+#define fdt_for_each_subnode(node, fdt, parent) \\r
+ for (node = fdt_first_subnode(fdt, parent); \\r
+ node >= 0; \\r
+ node = fdt_next_subnode(fdt, node))\r
\r
/**********************************************************************/\r
/* General functions */\r
/**********************************************************************/\r
-\r
#define fdt_get_header(fdt, field) \\r
- (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))\r
-#define fdt_magic(fdt) (fdt_get_header(fdt, magic))\r
-#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))\r
-#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))\r
-#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))\r
-#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))\r
-#define fdt_version(fdt) (fdt_get_header(fdt, version))\r
-#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))\r
-#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))\r
-#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))\r
-#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))\r
+ (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))\r
+#define fdt_magic(fdt) (fdt_get_header(fdt, magic))\r
+#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))\r
+#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))\r
+#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))\r
+#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))\r
+#define fdt_version(fdt) (fdt_get_header(fdt, version))\r
+#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))\r
+#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))\r
+#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))\r
+#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))\r
\r
#define __fdt_set_hdr(name) \\r
- static inline void fdt_set_##name(void *fdt, uint32_t val) \\r
- { \\r
- struct fdt_header *fdth = (struct fdt_header*)fdt; \\r
- fdth->name = cpu_to_fdt32(val); \\r
- }\r
-__fdt_set_hdr(magic);\r
-__fdt_set_hdr(totalsize);\r
-__fdt_set_hdr(off_dt_struct);\r
-__fdt_set_hdr(off_dt_strings);\r
-__fdt_set_hdr(off_mem_rsvmap);\r
-__fdt_set_hdr(version);\r
-__fdt_set_hdr(last_comp_version);\r
-__fdt_set_hdr(boot_cpuid_phys);\r
-__fdt_set_hdr(size_dt_strings);\r
-__fdt_set_hdr(size_dt_struct);\r
+ static inline void fdt_set_##name(void *fdt, uint32_t val) \\r
+ { \\r
+ struct fdt_header *fdth = (struct fdt_header *)fdt; \\r
+ fdth->name = cpu_to_fdt32(val); \\r
+ }\r
+__fdt_set_hdr (magic);\r
+__fdt_set_hdr (totalsize);\r
+__fdt_set_hdr (off_dt_struct);\r
+__fdt_set_hdr (off_dt_strings);\r
+__fdt_set_hdr (off_mem_rsvmap);\r
+__fdt_set_hdr (version);\r
+__fdt_set_hdr (last_comp_version);\r
+__fdt_set_hdr (boot_cpuid_phys);\r
+__fdt_set_hdr (size_dt_strings);\r
+__fdt_set_hdr (size_dt_struct);\r
#undef __fdt_set_hdr\r
\r
/**\r
* -FDT_ERR_BADVERSION,\r
* -FDT_ERR_BADSTATE, standard meanings, as above\r
*/\r
-int fdt_check_header(const void *fdt);\r
+int\r
+fdt_check_header (\r
+ const void *fdt\r
+ );\r
\r
/**\r
* fdt_move - move a device tree around in memory\r
* -FDT_ERR_BADVERSION,\r
* -FDT_ERR_BADSTATE, standard meanings\r
*/\r
-int fdt_move(const void *fdt, void *buf, int bufsize);\r
+int\r
+fdt_move (\r
+ const void *fdt,\r
+ void *buf,\r
+ int bufsize\r
+ );\r
\r
/**********************************************************************/\r
/* Read-only functions */\r
* a pointer to the string, on success\r
* NULL, if stroffset is out of bounds\r
*/\r
-const char *fdt_string(const void *fdt, int stroffset);\r
+const char *\r
+fdt_string (\r
+ const void *fdt,\r
+ int stroffset\r
+ );\r
+\r
+/**\r
+ * fdt_get_max_phandle - retrieves the highest phandle in a tree\r
+ * @fdt: pointer to the device tree blob\r
+ *\r
+ * fdt_get_max_phandle retrieves the highest phandle in the given\r
+ * device tree. This will ignore badly formatted phandles, or phandles\r
+ * with a value of 0 or -1.\r
+ *\r
+ * returns:\r
+ * the highest phandle on success\r
+ * 0, if no phandle was found in the device tree\r
+ * -1, if an error occurred\r
+ */\r
+uint32_t\r
+fdt_get_max_phandle (\r
+ const void *fdt\r
+ );\r
\r
/**\r
* fdt_num_mem_rsv - retrieve the number of memory reserve map entries\r
* returns:\r
* the number of entries\r
*/\r
-int fdt_num_mem_rsv(const void *fdt);\r
+int\r
+fdt_num_mem_rsv (\r
+ const void *fdt\r
+ );\r
\r
/**\r
* fdt_get_mem_rsv - retrieve one memory reserve map entry\r
* -FDT_ERR_BADVERSION,\r
* -FDT_ERR_BADSTATE, standard meanings\r
*/\r
-int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);\r
+int\r
+fdt_get_mem_rsv (\r
+ const void *fdt,\r
+ int n,\r
+ uint64_t *address,\r
+ uint64_t *size\r
+ );\r
\r
/**\r
* fdt_subnode_offset_namelen - find a subnode based on substring\r
* useful for finding subnodes based on a portion of a larger string,\r
* such as a full path.\r
*/\r
-int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,\r
- const char *name, int namelen);\r
+#ifndef SWIG /* Not available in Python */\r
+int\r
+fdt_subnode_offset_namelen (\r
+ const void *fdt,\r
+ int parentoffset,\r
+ const char *name,\r
+ int namelen\r
+ );\r
+\r
+#endif\r
+\r
/**\r
* fdt_subnode_offset - find a subnode of a given node\r
* @fdt: pointer to the device tree blob\r
* whose name excluding unit address matches the given name.\r
*\r
* returns:\r
- * structure block offset of the requested subnode (>=0), on success\r
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist\r
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag\r
+ * structure block offset of the requested subnode (>=0), on success\r
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist\r
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE\r
+ * tag\r
* -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings.\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings.\r
*/\r
-int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);\r
+int\r
+fdt_subnode_offset (\r
+ const void *fdt,\r
+ int parentoffset,\r
+ const char *name\r
+ );\r
+\r
+/**\r
+ * fdt_path_offset_namelen - find a tree node by its full path\r
+ * @fdt: pointer to the device tree blob\r
+ * @path: full path of the node to locate\r
+ * @namelen: number of characters of path to consider\r
+ *\r
+ * Identical to fdt_path_offset(), but only consider the first namelen\r
+ * characters of path as the path name.\r
+ */\r
+#ifndef SWIG /* Not available in Python */\r
+int\r
+fdt_path_offset_namelen (\r
+ const void *fdt,\r
+ const char *path,\r
+ int namelen\r
+ );\r
+\r
+#endif\r
\r
/**\r
* fdt_path_offset - find a tree node by its full path\r
* address).\r
*\r
* returns:\r
- * structure block offset of the node with the requested path (>=0), on success\r
- * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid\r
- * -FDT_ERR_NOTFOUND, if the requested node does not exist\r
+ * structure block offset of the node with the requested path (>=0), on\r
+ * success\r
+ * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid\r
+ * -FDT_ERR_NOTFOUND, if the requested node does not exist\r
* -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings.\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings.\r
*/\r
-int fdt_path_offset(const void *fdt, const char *path);\r
+int\r
+fdt_path_offset (\r
+ const void *fdt,\r
+ const char *path\r
+ );\r
\r
/**\r
* fdt_get_name - retrieve the name of a given node\r
* pointed to by lenp.\r
*\r
* returns:\r
- * pointer to the node's name, on success\r
- * If lenp is non-NULL, *lenp contains the length of that name (>=0)\r
- * NULL, on error\r
- * if lenp is non-NULL *lenp contains an error code (<0):\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE, standard meanings\r
+ * pointer to the node's name, on success\r
+ * If lenp is non-NULL, *lenp contains the length of that name\r
+ * (>=0)\r
+ * NULL, on error\r
+ * if lenp is non-NULL *lenp contains an error code (<0):\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\r
+ * tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE, standard meanings\r
*/\r
-const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);\r
+const char *\r
+fdt_get_name (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ int *lenp\r
+ );\r
\r
/**\r
* fdt_first_property_offset - find the offset of a node's first property\r
* the given structure block offset.\r
*\r
* returns:\r
- * structure block offset of the property (>=0), on success\r
- * -FDT_ERR_NOTFOUND, if the requested node has no properties\r
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag\r
+ * structure block offset of the property (>=0), on success\r
+ * -FDT_ERR_NOTFOUND, if the requested node has no properties\r
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag\r
* -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings.\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings.\r
*/\r
-int fdt_first_property_offset(const void *fdt, int nodeoffset);\r
+int\r
+fdt_first_property_offset (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**\r
* fdt_next_property_offset - step through a node's properties\r
* of the same node as the given property.\r
*\r
* returns:\r
- * structure block offset of the next property (>=0), on success\r
- * -FDT_ERR_NOTFOUND, if the given property is the last in its node\r
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag\r
+ * structure block offset of the next property (>=0), on success\r
+ * -FDT_ERR_NOTFOUND, if the given property is the last in its node\r
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag\r
* -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings.\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings.\r
+ */\r
+int\r
+fdt_next_property_offset (\r
+ const void *fdt,\r
+ int offset\r
+ );\r
+\r
+/**\r
+ * fdt_for_each_property_offset - iterate over all properties of a node\r
+ *\r
+ * @property_offset: property offset (int, lvalue)\r
+ * @fdt: FDT blob (const void *)\r
+ * @node: node offset (int)\r
+ *\r
+ * This is actually a wrapper around a for loop and would be used like so:\r
+ *\r
+ * fdt_for_each_property_offset(property, fdt, node) {\r
+ * Use property\r
+ * ...\r
+ * }\r
+ *\r
+ * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {\r
+ * Error handling\r
+ * }\r
+ *\r
+ * Note that this is implemented as a macro and property is used as\r
+ * iterator in the loop. The node variable can be constant or even a\r
+ * literal.\r
*/\r
-int fdt_next_property_offset(const void *fdt, int offset);\r
+#define fdt_for_each_property_offset(property, fdt, node) \\r
+ for (property = fdt_first_property_offset(fdt, node); \\r
+ property >= 0; \\r
+ property = fdt_next_property_offset(fdt, property))\r
\r
/**\r
* fdt_get_property_by_offset - retrieve the property at a given offset\r
* also returned, in the integer pointed to by lenp.\r
*\r
* returns:\r
- * pointer to the structure representing the property\r
- * if lenp is non-NULL, *lenp contains the length of the property\r
- * value (>=0)\r
- * NULL, on error\r
- * if lenp is non-NULL, *lenp contains an error code (<0):\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-const struct fdt_property *fdt_get_property_by_offset(const void *fdt,\r
- int offset,\r
- int *lenp);\r
+ * pointer to the structure representing the property\r
+ * if lenp is non-NULL, *lenp contains the length of the property\r
+ * value (>=0)\r
+ * NULL, on error\r
+ * if lenp is non-NULL, *lenp contains an error code (<0):\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+const struct fdt_property *\r
+fdt_get_property_by_offset (\r
+ const void *fdt,\r
+ int offset,\r
+ int *lenp\r
+ );\r
\r
/**\r
* fdt_get_property_namelen - find a property based on substring\r
* @namelen: number of characters of name to consider\r
* @lenp: pointer to an integer variable (will be overwritten) or NULL\r
*\r
- * Identical to fdt_get_property_namelen(), but only examine the first\r
- * namelen characters of name for matching the property name.\r
+ * Identical to fdt_get_property(), but only examine the first namelen\r
+ * characters of name for matching the property name.\r
*/\r
-const struct fdt_property *fdt_get_property_namelen(const void *fdt,\r
- int nodeoffset,\r
- const char *name,\r
- int namelen, int *lenp);\r
+#ifndef SWIG /* Not available in Python */\r
+const struct fdt_property *\r
+fdt_get_property_namelen (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int namelen,\r
+ int *lenp\r
+ );\r
+\r
+#endif\r
\r
/**\r
* fdt_get_property - find a given property in a given node\r
* integer pointed to by lenp.\r
*\r
* returns:\r
- * pointer to the structure representing the property\r
- * if lenp is non-NULL, *lenp contains the length of the property\r
- * value (>=0)\r
- * NULL, on error\r
- * if lenp is non-NULL, *lenp contains an error code (<0):\r
- * -FDT_ERR_NOTFOUND, node does not have named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,\r
- const char *name, int *lenp);\r
-static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,\r
- const char *name,\r
- int *lenp)\r
+ * pointer to the structure representing the property\r
+ * if lenp is non-NULL, *lenp contains the length of the property\r
+ * value (>=0)\r
+ * NULL, on error\r
+ * if lenp is non-NULL, *lenp contains an error code (<0):\r
+ * -FDT_ERR_NOTFOUND, node does not have named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\r
+ * tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+const struct fdt_property *\r
+fdt_get_property (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int *lenp\r
+ );\r
+\r
+static inline struct fdt_property *\r
+fdt_get_property_w (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int *lenp\r
+ )\r
{\r
- return (struct fdt_property *)(uintptr_t)\r
- fdt_get_property(fdt, nodeoffset, name, lenp);\r
+ return (struct fdt_property *)(uintptr_t)\r
+ fdt_get_property (fdt, nodeoffset, name, lenp);\r
}\r
\r
/**\r
* block, not a new copy of the name).\r
*\r
* returns:\r
- * pointer to the property's value\r
- * if lenp is non-NULL, *lenp contains the length of the property\r
- * value (>=0)\r
- * if namep is non-NULL *namep contiains a pointer to the property\r
- * name.\r
- * NULL, on error\r
- * if lenp is non-NULL, *lenp contains an error code (<0):\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-const void *fdt_getprop_by_offset(const void *fdt, int offset,\r
- const char **namep, int *lenp);\r
+ * pointer to the property's value\r
+ * if lenp is non-NULL, *lenp contains the length of the property\r
+ * value (>=0)\r
+ * if namep is non-NULL *namep contiains a pointer to the property\r
+ * name.\r
+ * NULL, on error\r
+ * if lenp is non-NULL, *lenp contains an error code (<0):\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+#ifndef SWIG /* This function is not useful in Python */\r
+const void *\r
+fdt_getprop_by_offset (\r
+ const void *fdt,\r
+ int offset,\r
+ const char **namep,\r
+ int *lenp\r
+ );\r
+\r
+#endif\r
\r
/**\r
* fdt_getprop_namelen - get property value based on substring\r
* Identical to fdt_getprop(), but only examine the first namelen\r
* characters of name for matching the property name.\r
*/\r
-const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,\r
- const char *name, int namelen, int *lenp);\r
+#ifndef SWIG /* Not available in Python */\r
+const void *\r
+fdt_getprop_namelen (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int namelen,\r
+ int *lenp\r
+ );\r
+\r
+static inline void *\r
+fdt_getprop_namelen_w (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int namelen,\r
+ int *lenp\r
+ )\r
+{\r
+ return (void *)(uintptr_t)fdt_getprop_namelen (\r
+ fdt,\r
+ nodeoffset,\r
+ name,\r
+ namelen,\r
+ lenp\r
+ );\r
+}\r
+\r
+#endif\r
\r
/**\r
* fdt_getprop - retrieve the value of a given property\r
* returned, in the integer pointed to by lenp.\r
*\r
* returns:\r
- * pointer to the property's value\r
- * if lenp is non-NULL, *lenp contains the length of the property\r
- * value (>=0)\r
- * NULL, on error\r
- * if lenp is non-NULL, *lenp contains an error code (<0):\r
- * -FDT_ERR_NOTFOUND, node does not have named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-const void *fdt_getprop(const void *fdt, int nodeoffset,\r
- const char *name, int *lenp);\r
-static inline void *fdt_getprop_w(void *fdt, int nodeoffset,\r
- const char *name, int *lenp)\r
+ * pointer to the property's value\r
+ * if lenp is non-NULL, *lenp contains the length of the property\r
+ * value (>=0)\r
+ * NULL, on error\r
+ * if lenp is non-NULL, *lenp contains an error code (<0):\r
+ * -FDT_ERR_NOTFOUND, node does not have named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\r
+ * tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+const void *\r
+fdt_getprop (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int *lenp\r
+ );\r
+\r
+static inline void *\r
+fdt_getprop_w (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int *lenp\r
+ )\r
{\r
- return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);\r
+ return (void *)(uintptr_t)fdt_getprop (fdt, nodeoffset, name, lenp);\r
}\r
\r
/**\r
* structure block offset nodeoffset.\r
*\r
* returns:\r
- * the phandle of the node at nodeoffset, on success (!= 0, != -1)\r
- * 0, if the node has no phandle, or another error occurs\r
+ * the phandle of the node at nodeoffset, on success (!= 0, != -1)\r
+ * 0, if the node has no phandle, or another error occurs\r
*/\r
-uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);\r
+uint32_t\r
+fdt_get_phandle (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**\r
* fdt_get_alias_namelen - get alias based on substring\r
* Identical to fdt_get_alias(), but only examine the first namelen\r
* characters of name for matching the alias name.\r
*/\r
-const char *fdt_get_alias_namelen(const void *fdt,\r
- const char *name, int namelen);\r
+#ifndef SWIG /* Not available in Python */\r
+const char *\r
+fdt_get_alias_namelen (\r
+ const void *fdt,\r
+ const char *name,\r
+ int namelen\r
+ );\r
+\r
+#endif\r
\r
/**\r
- * fdt_get_alias - retreive the path referenced by a given alias\r
+ * fdt_get_alias - retrieve the path referenced by a given alias\r
* @fdt: pointer to the device tree blob\r
* @name: name of the alias th look up\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
- * NULL, if the given alias or the /aliases node does not exist\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
+const char *\r
+fdt_get_alias (\r
+ const void *fdt,\r
+ const char *name\r
+ );\r
\r
/**\r
* fdt_get_path - determine the full path of a node\r
* structure from the start to nodeoffset.\r
*\r
* returns:\r
- * 0, on success\r
- * buf contains the absolute path of the node at\r
- * nodeoffset, as a NUL-terminated string.\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)\r
- * characters and will not fit in the given buffer.\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * 0, on success\r
+ * buf contains the absolute path of the node at\r
+ * nodeoffset, as a NUL-terminated string.\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)\r
+ * characters and will not fit in the given buffer.\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);\r
+int\r
+fdt_get_path (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ char *buf,\r
+ int buflen\r
+ );\r
\r
/**\r
* fdt_supernode_atdepth_offset - find a specific ancestor of a node\r
* fdt_supernode_atdepth_offset() finds an ancestor of the given node\r
* at a specific depth from the root (where the root itself has depth\r
* 0, its immediate subnodes depth 1 and so forth). So\r
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);\r
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);\r
* will always return 0, the offset of the root node. If the node at\r
* nodeoffset has depth D, then:\r
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);\r
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);\r
* will return nodeoffset itself.\r
*\r
* NOTE: This function is expensive, as it must scan the device tree\r
* structure from the start to nodeoffset.\r
*\r
* returns:\r
-\r
- * structure block offset of the node at node offset's ancestor\r
- * of depth supernodedepth (>=0), on success\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
-* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * structure block offset of the node at node offset's ancestor\r
+ * of depth supernodedepth (>=0), on success\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of\r
+ * nodeoffset\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,\r
- int supernodedepth, int *nodedepth);\r
+int\r
+fdt_supernode_atdepth_offset (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ int supernodedepth,\r
+ int *nodedepth\r
+ );\r
\r
/**\r
* fdt_node_depth - find the depth of a given node\r
* structure from the start to nodeoffset.\r
*\r
* returns:\r
- * depth of the node at nodeoffset (>=0), on success\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * depth of the node at nodeoffset (>=0), on success\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_node_depth(const void *fdt, int nodeoffset);\r
+int\r
+fdt_node_depth (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**\r
* fdt_parent_offset - find the parent of a given node\r
* structure from the start to nodeoffset, *twice*.\r
*\r
* returns:\r
- * structure block offset of the parent of the node at nodeoffset\r
- * (>=0), on success\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * structure block offset of the parent of the node at nodeoffset\r
+ * (>=0), on success\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_parent_offset(const void *fdt, int nodeoffset);\r
+int\r
+fdt_parent_offset (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**\r
* fdt_node_offset_by_prop_value - find nodes with a given property value\r
*\r
* To iterate through all nodes matching the criterion, the following\r
* idiom can be used:\r
- * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,\r
- * propval, proplen);\r
- * while (offset != -FDT_ERR_NOTFOUND) {\r
- * // other code here\r
- * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,\r
- * propval, proplen);\r
- * }\r
+ * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,\r
+ * propval, proplen);\r
+ * while (offset != -FDT_ERR_NOTFOUND) {\r
+ * // other code here\r
+ * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,\r
+ * propval, proplen);\r
+ * }\r
*\r
* Note the -1 in the first call to the function, if 0 is used here\r
* instead, the function will never locate the root node, even if it\r
* matches the criterion.\r
*\r
* returns:\r
- * structure block offset of the located node (>= 0, >startoffset),\r
- * on success\r
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the\r
- * tree after startoffset\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * structure block offset of the located node (>= 0, >startoffset),\r
+ * on success\r
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the\r
+ * tree after startoffset\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,\r
- const char *propname,\r
- const void *propval, int proplen);\r
+int\r
+fdt_node_offset_by_prop_value (\r
+ const void *fdt,\r
+ int startoffset,\r
+ const char *propname,\r
+ const void *propval,\r
+ int proplen\r
+ );\r
\r
/**\r
* fdt_node_offset_by_phandle - find the node with a given phandle\r
* undefined.\r
*\r
* returns:\r
- * structure block offset of the located node (>= 0), on success\r
- * -FDT_ERR_NOTFOUND, no node with that phandle exists\r
- * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * structure block offset of the located node (>= 0), on success\r
+ * -FDT_ERR_NOTFOUND, no node with that phandle exists\r
+ * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);\r
+int\r
+fdt_node_offset_by_phandle (\r
+ const void *fdt,\r
+ uint32_t phandle\r
+ );\r
\r
/**\r
* fdt_node_check_compatible: check a node's compatible property\r
* it returns non-zero otherwise, or on error.\r
*\r
* returns:\r
- * 0, if the node has a 'compatible' property listing the given string\r
- * 1, if the node has a 'compatible' property, but it does not list\r
- * the given string\r
- * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property\r
- * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ * 0, if the node has a 'compatible' property listing the given string\r
+ * 1, if the node has a 'compatible' property, but it does not list\r
+ * the given string\r
+ * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property\r
+ * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
*/\r
-int fdt_node_check_compatible(const void *fdt, int nodeoffset,\r
- const char *compatible);\r
+int\r
+fdt_node_check_compatible (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *compatible\r
+ );\r
\r
/**\r
* fdt_node_offset_by_compatible - find nodes with a given 'compatible' value\r
*\r
* To iterate through all nodes matching the criterion, the following\r
* idiom can be used:\r
- * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);\r
- * while (offset != -FDT_ERR_NOTFOUND) {\r
- * // other code here\r
- * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);\r
- * }\r
+ * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);\r
+ * while (offset != -FDT_ERR_NOTFOUND) {\r
+ * // other code here\r
+ * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);\r
+ * }\r
*\r
* Note the -1 in the first call to the function, if 0 is used here\r
* instead, the function will never locate the root node, even if it\r
* matches the criterion.\r
*\r
* returns:\r
- * structure block offset of the located node (>= 0, >startoffset),\r
- * on success\r
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the\r
- * tree after startoffset\r
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE, standard meanings\r
- */\r
-int fdt_node_offset_by_compatible(const void *fdt, int startoffset,\r
- const char *compatible);\r
+ * structure block offset of the located node (>= 0, >startoffset),\r
+ * on success\r
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the\r
+ * tree after startoffset\r
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE, standard meanings\r
+ */\r
+int\r
+fdt_node_offset_by_compatible (\r
+ const void *fdt,\r
+ int startoffset,\r
+ const char *compatible\r
+ );\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\r
+fdt_stringlist_contains (\r
+ const char *strlist,\r
+ int listlen,\r
+ const char *str\r
+ );\r
+\r
+/**\r
+ * fdt_stringlist_count - count the number of strings in a string list\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of a tree node\r
+ * @property: name of the property containing the string list\r
+ * @return:\r
+ * the number of strings in the given property\r
+ * -FDT_ERR_BADVALUE if the property value is not NUL-terminated\r
+ * -FDT_ERR_NOTFOUND if the property does not exist\r
+ */\r
+int\r
+fdt_stringlist_count (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *property\r
+ );\r
+\r
+/**\r
+ * fdt_stringlist_search - find a string in a string list and return its index\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of a tree node\r
+ * @property: name of the property containing the string list\r
+ * @string: string to look up in the string list\r
+ *\r
+ * Note that it is possible for this function to succeed on property values\r
+ * that are not NUL-terminated. That's because the function will stop after\r
+ * finding the first occurrence of @string. This can for example happen with\r
+ * small-valued cell properties, such as #address-cells, when searching for\r
+ * the empty string.\r
+ *\r
+ * @return:\r
+ * the index of the string in the list of strings\r
+ * -FDT_ERR_BADVALUE if the property value is not NUL-terminated\r
+ * -FDT_ERR_NOTFOUND if the property does not exist or does not contain\r
+ * the given string\r
+ */\r
+int\r
+fdt_stringlist_search (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *property,\r
+ const char *string\r
+ );\r
+\r
+/**\r
+ * fdt_stringlist_get() - obtain the string at a given index in a string list\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of a tree node\r
+ * @property: name of the property containing the string list\r
+ * @index: index of the string to return\r
+ * @lenp: return location for the string length or an error code on failure\r
+ *\r
+ * Note that this will successfully extract strings from properties with\r
+ * non-NUL-terminated values. For example on small-valued cell properties\r
+ * this function will return the empty string.\r
+ *\r
+ * If non-NULL, the length of the string (on success) or a negative error-code\r
+ * (on failure) will be stored in the integer pointer to by lenp.\r
+ *\r
+ * @return:\r
+ * A pointer to the string at the given index in the string list or NULL on\r
+ * failure. On success the length of the string will be stored in the memory\r
+ * location pointed to by the lenp parameter, if non-NULL. On failure one of\r
+ * the following negative error codes will be returned in the lenp parameter\r
+ * (if non-NULL):\r
+ * -FDT_ERR_BADVALUE if the property value is not NUL-terminated\r
+ * -FDT_ERR_NOTFOUND if the property does not exist\r
+ */\r
+const char *\r
+fdt_stringlist_get (\r
+ const void *fdt,\r
+ int nodeoffset,\r
+ const char *property,\r
+ int index,\r
+ int *lenp\r
+ );\r
+\r
+/**********************************************************************/\r
+/* Read-only functions (addressing related) */\r
+/**********************************************************************/\r
+\r
+/**\r
+ * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells\r
+ *\r
+ * This is the maximum value for #address-cells, #size-cells and\r
+ * similar properties that will be processed by libfdt. IEE1275\r
+ * requires that OF implementations handle values up to 4.\r
+ * Implementations may support larger values, but in practice higher\r
+ * values aren't used.\r
+ */\r
+#define FDT_MAX_NCELLS 4\r
+\r
+/**\r
+ * fdt_address_cells - retrieve address size for a bus represented in the tree\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of the node to find the address size for\r
+ *\r
+ * When the node has a valid #address-cells property, returns its value.\r
+ *\r
+ * returns:\r
+ * 0 <= n < FDT_MAX_NCELLS, on success\r
+ * 2, if the node has no #address-cells property\r
+ * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid\r
+ * #address-cells property\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_address_cells (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
+\r
+/**\r
+ * fdt_size_cells - retrieve address range size for a bus represented in the\r
+ * tree\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of the node to find the address range size for\r
+ *\r
+ * When the node has a valid #size-cells property, returns its value.\r
+ *\r
+ * returns:\r
+ * 0 <= n < FDT_MAX_NCELLS, on success\r
+ * 2, if the node has no #address-cells property\r
+ * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid\r
+ * #size-cells property\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_size_cells (\r
+ const void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**********************************************************************/\r
/* Write-in-place functions */\r
/**********************************************************************/\r
\r
+/**\r
+ * fdt_setprop_inplace_namelen_partial - change a property's value,\r
+ * but not its size\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of the node whose property to change\r
+ * @name: name of the property to change\r
+ * @namelen: number of characters of name to consider\r
+ * @idx: index of the property to change in the array\r
+ * @val: pointer to data to replace the property value with\r
+ * @len: length of the property value\r
+ *\r
+ * Identical to fdt_setprop_inplace(), but modifies the given property\r
+ * starting from the given index, and using only the first characters\r
+ * of the name. It is useful when you want to manipulate only one value of\r
+ * an array and you have a string that doesn't end with \0.\r
+ */\r
+#ifndef SWIG /* Not available in Python */\r
+int\r
+fdt_setprop_inplace_namelen_partial (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int namelen,\r
+ uint32_t idx,\r
+ const void *val,\r
+ int len\r
+ );\r
+\r
+#endif\r
+\r
/**\r
* fdt_setprop_inplace - change a property's value, but not its size\r
* @fdt: pointer to the device tree blob\r
* of the tree.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, if len is not equal to the property's current length\r
- * -FDT_ERR_NOTFOUND, node does not have the named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, if len is not equal to the property's current length\r
+ * -FDT_ERR_NOTFOUND, node does not have the named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,\r
- const void *val, int len);\r
+#ifndef SWIG /* Not available in Python */\r
+int\r
+fdt_setprop_inplace (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ const void *val,\r
+ int len\r
+ );\r
+\r
+#endif\r
\r
/**\r
* fdt_setprop_inplace_u32 - change the value of a 32-bit integer property\r
* of the tree.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 4\r
- * -FDT_ERR_NOTFOUND, node does not have the named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,\r
- const char *name, uint32_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 4\r
+ * -FDT_ERR_NOTFOUND, node does not have the named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_setprop_inplace_u32 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\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
+\r
+ return fdt_setprop_inplace (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
* of the tree.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 8\r
- * -FDT_ERR_NOTFOUND, node does not have the named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,\r
- const char *name, uint64_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 8\r
+ * -FDT_ERR_NOTFOUND, node does not have the named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_setprop_inplace_u64 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint64_t val\r
+ )\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
+\r
+ return fdt_setprop_inplace (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
*\r
* This is an alternative name for fdt_setprop_inplace_u32()\r
*/\r
-static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,\r
- const char *name, uint32_t val)\r
+static inline int\r
+fdt_setprop_inplace_cell (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\r
{\r
- return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);\r
+ return fdt_setprop_inplace_u32 (fdt, nodeoffset, name, val);\r
}\r
\r
/**\r
* tree.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOTFOUND, node does not have the named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOTFOUND, node does not have the named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_nop_property(void *fdt, int nodeoffset, const char *name);\r
+int\r
+fdt_nop_property (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name\r
+ );\r
\r
/**\r
* fdt_nop_node - replace a node (subtree) with nop tags\r
* move any other part of the tree.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_nop_node(void *fdt, int nodeoffset);\r
+int\r
+fdt_nop_node (\r
+ void *fdt,\r
+ int nodeoffset\r
+ );\r
\r
/**********************************************************************/\r
/* Sequential write functions */\r
/**********************************************************************/\r
\r
-int fdt_create(void *buf, int bufsize);\r
-int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);\r
-int fdt_finish_reservemap(void *fdt);\r
-int fdt_begin_node(void *fdt, const char *name);\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
+int\r
+fdt_create (\r
+ void *buf,\r
+ int bufsize\r
+ );\r
+\r
+int\r
+fdt_resize (\r
+ void *fdt,\r
+ void *buf,\r
+ int bufsize\r
+ );\r
+\r
+int\r
+fdt_add_reservemap_entry (\r
+ void *fdt,\r
+ uint64_t addr,\r
+ uint64_t size\r
+ );\r
+\r
+int\r
+fdt_finish_reservemap (\r
+ void *fdt\r
+ );\r
+\r
+int\r
+fdt_begin_node (\r
+ void *fdt,\r
+ const char *name\r
+ );\r
+\r
+int\r
+fdt_property (\r
+ void *fdt,\r
+ const char *name,\r
+ const void *val,\r
+ int len\r
+ );\r
+\r
+static inline int\r
+fdt_property_u32 (\r
+ void *fdt,\r
+ const char *name,\r
+ uint32_t val\r
+ )\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
+\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
+static inline int\r
+fdt_property_u64 (\r
+ void *fdt,\r
+ const char *name,\r
+ uint64_t val\r
+ )\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
+\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\r
+fdt_property_cell (\r
+ void *fdt,\r
+ const char *name,\r
+ uint32_t val\r
+ )\r
{\r
- return fdt_property_u32(fdt, name, val);\r
+ return fdt_property_u32 (fdt, name, val);\r
}\r
+\r
+/**\r
+ * fdt_property_placeholder - add a new property and return a ptr to its value\r
+ *\r
+ * @fdt: pointer to the device tree blob\r
+ * @name: name of property to add\r
+ * @len: length of property value in bytes\r
+ * @valp: returns a pointer to where where the value should be placed\r
+ *\r
+ * returns:\r
+ * 0, on success\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_NOSPACE, standard meanings\r
+ */\r
+int\r
+fdt_property_placeholder (\r
+ void *fdt,\r
+ const char *name,\r
+ int len,\r
+ void **valp\r
+ );\r
+\r
#define fdt_property_string(fdt, name, str) \\r
- fdt_property(fdt, name, str, strlen(str)+1)\r
-int fdt_end_node(void *fdt);\r
-int fdt_finish(void *fdt);\r
+ fdt_property(fdt, name, str, strlen(str)+1)\r
+int\r
+fdt_end_node (\r
+ void *fdt\r
+ );\r
+\r
+int\r
+fdt_finish (\r
+ void *fdt\r
+ );\r
\r
/**********************************************************************/\r
/* Read-write functions */\r
/**********************************************************************/\r
\r
-int fdt_create_empty_tree(void *buf, int bufsize);\r
-int fdt_open_into(const void *fdt, void *buf, int bufsize);\r
-int fdt_pack(void *fdt);\r
+int\r
+fdt_create_empty_tree (\r
+ void *buf,\r
+ int bufsize\r
+ );\r
+\r
+int\r
+fdt_open_into (\r
+ const void *fdt,\r
+ void *buf,\r
+ int bufsize\r
+ );\r
+\r
+int\r
+fdt_pack (\r
+ void *fdt\r
+ );\r
\r
/**\r
* fdt_add_mem_rsv - add one memory reserve map entry\r
* therefore change the indexes of some entries in the table.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new reservation entry\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new reservation entry\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);\r
+int\r
+fdt_add_mem_rsv (\r
+ void *fdt,\r
+ uint64_t address,\r
+ uint64_t size\r
+ );\r
\r
/**\r
* fdt_del_mem_rsv - remove a memory reserve map entry\r
* therefore change the indexes of some entries in the table.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there\r
- * are less than n+1 reserve map entries)\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there\r
+ * are less than n+1 reserve map entries)\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_del_mem_rsv(void *fdt, int n);\r
+int\r
+fdt_del_mem_rsv (\r
+ void *fdt,\r
+ int n\r
+ );\r
\r
/**\r
* fdt_set_name - change the name of a given node\r
* therefore change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob\r
- * to contain the new name\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob\r
+ * to contain the new name\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE, standard meanings\r
*/\r
-int fdt_set_name(void *fdt, int nodeoffset, const char *name);\r
+int\r
+fdt_set_name (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name\r
+ );\r
\r
/**\r
* fdt_setprop - create or change a property\r
* therefore change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,\r
- const void *val, int len);\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_setprop (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ const void *val,\r
+ int len\r
+ );\r
+\r
+/**\r
+ * fdt_setprop _placeholder - allocate space for a property\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of the node whose property to change\r
+ * @name: name of the property to change\r
+ * @len: length of the property value\r
+ * @prop_data: return pointer to property data\r
+ *\r
+ * fdt_setprop_placeholer() allocates the named property in the given node.\r
+ * If the property exists it is resized. In either case a pointer to the\r
+ * property data is returned.\r
+ *\r
+ * This function may insert or delete data from the blob, and will\r
+ * therefore change the offsets of some existing nodes.\r
+ *\r
+ * returns:\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_setprop_placeholder (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ int len,\r
+ void **prop_data\r
+ );\r
\r
/**\r
* fdt_setprop_u32 - set a property to a 32-bit integer\r
* therefore change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,\r
- uint32_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_setprop_u32 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\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
+\r
+ return fdt_setprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
* therefore change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,\r
- uint64_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_setprop_u64 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint64_t val\r
+ )\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
+\r
+ return fdt_setprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
*\r
* This is an alternative name for fdt_setprop_u32()\r
*/\r
-static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,\r
- uint32_t val)\r
+static inline int\r
+fdt_setprop_cell (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\r
{\r
- return fdt_setprop_u32(fdt, nodeoffset, name, val);\r
+ return fdt_setprop_u32 (fdt, nodeoffset, name, val);\r
}\r
\r
/**\r
* therefore change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
#define fdt_setprop_string(fdt, nodeoffset, name, str) \\r
- fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\r
+ fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\r
+\r
+/**\r
+ * fdt_setprop_empty - set a property to an empty value\r
+ * @fdt: pointer to the device tree blob\r
+ * @nodeoffset: offset of the node whose property to change\r
+ * @name: name of the property to change\r
+ *\r
+ * fdt_setprop_empty() sets the value of the named property in the\r
+ * given node to an empty (zero length) value, or creates a new empty\r
+ * property if it does not already exist.\r
+ *\r
+ * This function may insert or delete data from the blob, and will\r
+ * therefore change the offsets of some existing nodes.\r
+ *\r
+ * returns:\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+#define fdt_setprop_empty(fdt, nodeoffset, name) \\r
+ fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)\r
\r
/**\r
* fdt_appendprop - append to or create a property\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-int fdt_appendprop(void *fdt, int nodeoffset, const char *name,\r
- const void *val, int len);\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_appendprop (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ const void *val,\r
+ int len\r
+ );\r
\r
/**\r
* fdt_appendprop_u32 - append a 32-bit integer value to a property\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,\r
- const char *name, uint32_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_appendprop_u32 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\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
+\r
+ return fdt_appendprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
- */\r
-static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,\r
- const char *name, uint64_t val)\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+static inline int\r
+fdt_appendprop_u64 (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint64_t val\r
+ )\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
+\r
+ return fdt_appendprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));\r
}\r
\r
/**\r
*\r
* This is an alternative name for fdt_appendprop_u32()\r
*/\r
-static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,\r
- const char *name, uint32_t val)\r
+static inline int\r
+fdt_appendprop_cell (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name,\r
+ uint32_t val\r
+ )\r
{\r
- return fdt_appendprop_u32(fdt, nodeoffset, name, val);\r
+ return fdt_appendprop_u32 (fdt, nodeoffset, name, val);\r
}\r
\r
/**\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
- * contain the new property value\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to\r
+ * contain the new property value\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
#define fdt_appendprop_string(fdt, nodeoffset, name, str) \\r
- fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\r
+ fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\r
\r
/**\r
* fdt_delprop - delete a property\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_NOTFOUND, node does not have the named property\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_NOTFOUND, node does not have the named property\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_delprop(void *fdt, int nodeoffset, const char *name);\r
+int\r
+fdt_delprop (\r
+ void *fdt,\r
+ int nodeoffset,\r
+ const char *name\r
+ );\r
\r
/**\r
* fdt_add_subnode_namelen - creates a new node based on substring\r
* creating subnodes based on a portion of a larger string, such as a\r
* full path.\r
*/\r
-int fdt_add_subnode_namelen(void *fdt, int parentoffset,\r
- const char *name, int namelen);\r
+#ifndef SWIG /* Not available in Python */\r
+int\r
+fdt_add_subnode_namelen (\r
+ void *fdt,\r
+ int parentoffset,\r
+ const char *name,\r
+ int namelen\r
+ );\r
+\r
+#endif\r
\r
/**\r
* fdt_add_subnode - creates a new node\r
* change the offsets of some existing nodes.\r
\r
* returns:\r
- * structure block offset of the created nodeequested subnode (>=0), on success\r
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist\r
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag\r
- * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of\r
- * the given name\r
- * -FDT_ERR_NOSPACE, if there is insufficient free space in the\r
- * blob to contain the new node\r
- * -FDT_ERR_NOSPACE\r
- * -FDT_ERR_BADLAYOUT\r
+ * structure block offset of the created nodeequested subnode (>=0), on\r
+ * success\r
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist\r
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE\r
+ * tag\r
+ * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of\r
+ * the given name\r
+ * -FDT_ERR_NOSPACE, if there is insufficient free space in the\r
+ * blob to contain the new node\r
+ * -FDT_ERR_NOSPACE\r
+ * -FDT_ERR_BADLAYOUT\r
* -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings.\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings.\r
*/\r
-int fdt_add_subnode(void *fdt, int parentoffset, const char *name);\r
+int\r
+fdt_add_subnode (\r
+ void *fdt,\r
+ int parentoffset,\r
+ const char *name\r
+ );\r
\r
/**\r
* fdt_del_node - delete a node (subtree)\r
* change the offsets of some existing nodes.\r
*\r
* returns:\r
- * 0, on success\r
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
- * -FDT_ERR_BADLAYOUT,\r
- * -FDT_ERR_BADMAGIC,\r
- * -FDT_ERR_BADVERSION,\r
- * -FDT_ERR_BADSTATE,\r
- * -FDT_ERR_BADSTRUCTURE,\r
- * -FDT_ERR_TRUNCATED, standard meanings\r
+ * 0, on success\r
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
+ */\r
+int\r
+fdt_del_node (\r
+ void *fdt,\r
+ int nodeoffset\r
+ );\r
+\r
+/**\r
+ * fdt_overlay_apply - Applies a DT overlay on a base DT\r
+ * @fdt: pointer to the base device tree blob\r
+ * @fdto: pointer to the device tree overlay blob\r
+ *\r
+ * fdt_overlay_apply() will apply the given device tree overlay on the\r
+ * given base device tree.\r
+ *\r
+ * Expect the base device tree to be modified, even if the function\r
+ * returns an error.\r
+ *\r
+ * returns:\r
+ * 0, on success\r
+ * -FDT_ERR_NOSPACE, there's not enough space in the base device tree\r
+ * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or\r
+ * properties in the base DT\r
+ * -FDT_ERR_BADPHANDLE,\r
+ * -FDT_ERR_BADOVERLAY,\r
+ * -FDT_ERR_NOPHANDLES,\r
+ * -FDT_ERR_INTERNAL,\r
+ * -FDT_ERR_BADLAYOUT,\r
+ * -FDT_ERR_BADMAGIC,\r
+ * -FDT_ERR_BADOFFSET,\r
+ * -FDT_ERR_BADPATH,\r
+ * -FDT_ERR_BADVERSION,\r
+ * -FDT_ERR_BADSTRUCTURE,\r
+ * -FDT_ERR_BADSTATE,\r
+ * -FDT_ERR_TRUNCATED, standard meanings\r
*/\r
-int fdt_del_node(void *fdt, int nodeoffset);\r
+int\r
+fdt_overlay_apply (\r
+ void *fdt,\r
+ void *fdto\r
+ );\r
\r
/**********************************************************************/\r
/* Debugging / informational functions */\r
/**********************************************************************/\r
\r
-const char *fdt_strerror(int errval);\r
+const char *\r
+fdt_strerror (\r
+ int errval\r
+ );\r
\r
#endif /* _LIBFDT_H */\r