aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/libfdt/libfdt.h
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-09-28 17:25:59 -0400
committerRob Herring <rob.herring@calxeda.com>2012-10-01 12:11:35 -0400
commitcd296721a9645f9f28800a072490fa15458d1fb7 (patch)
tree492b9a268a48af07844fbbd39519f95676ee73fe /scripts/dtc/libfdt/libfdt.h
parentacc2097934b5403b97f95763fe99fc115b818061 (diff)
dtc: import latest upstream dtc
This updates scripts/dtc to commit 317a5d9 "dtc: zero out new label objects" from git://git.jdl.com/software/dtc.git. This adds features such as: * /bits/ syntax for cell data. * Math expressions within cell data. * The ability to delete properties or nodes. * Support for #line directives in the input file, which allows the use of cpp on *.dts. * -i command-line option (/include/ path) * -W/-E command-line options for error/warning control. * Removal of spew to STDOUT containing the filename being compiled. * Many additions to the libfdt API. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Jon Loeliger <jdl@jdl.com> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'scripts/dtc/libfdt/libfdt.h')
-rw-r--r--scripts/dtc/libfdt/libfdt.h440
1 files changed, 421 insertions, 19 deletions
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index ff6246f000ce..73f49759a5e7 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -61,7 +61,7 @@
61#define FDT_ERR_NOTFOUND 1 61#define FDT_ERR_NOTFOUND 1
62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ 62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
63#define FDT_ERR_EXISTS 2 63#define FDT_ERR_EXISTS 2
64 /* FDT_ERR_EXISTS: Attempted to create a node or property which 64 /* FDT_ERR_EXISTS: Attemped to create a node or property which
65 * already exists */ 65 * already exists */
66#define FDT_ERR_NOSPACE 3 66#define FDT_ERR_NOSPACE 3
67 /* FDT_ERR_NOSPACE: Operation needed to expand the device 67 /* FDT_ERR_NOSPACE: Operation needed to expand the device
@@ -122,7 +122,7 @@
122/* Low-level functions (you probably don't need these) */ 122/* Low-level functions (you probably don't need these) */
123/**********************************************************************/ 123/**********************************************************************/
124 124
125const void *fdt_offset_ptr(const void *fdt, int offset, int checklen); 125const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
126static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) 126static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
127{ 127{
128 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); 128 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
@@ -156,7 +156,7 @@ int fdt_next_node(const void *fdt, int offset, int *depth);
156#define __fdt_set_hdr(name) \ 156#define __fdt_set_hdr(name) \
157 static inline void fdt_set_##name(void *fdt, uint32_t val) \ 157 static inline void fdt_set_##name(void *fdt, uint32_t val) \
158 { \ 158 { \
159 struct fdt_header *fdth = fdt; \ 159 struct fdt_header *fdth = (struct fdt_header*)fdt; \
160 fdth->name = cpu_to_fdt32(val); \ 160 fdth->name = cpu_to_fdt32(val); \
161 } 161 }
162__fdt_set_hdr(magic); 162__fdt_set_hdr(magic);
@@ -343,6 +343,91 @@ int fdt_path_offset(const void *fdt, const char *path);
343const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); 343const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
344 344
345/** 345/**
346 * fdt_first_property_offset - find the offset of a node's first property
347 * @fdt: pointer to the device tree blob
348 * @nodeoffset: structure block offset of a node
349 *
350 * fdt_first_property_offset() finds the first property of the node at
351 * the given structure block offset.
352 *
353 * returns:
354 * structure block offset of the property (>=0), on success
355 * -FDT_ERR_NOTFOUND, if the requested node has no properties
356 * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
357 * -FDT_ERR_BADMAGIC,
358 * -FDT_ERR_BADVERSION,
359 * -FDT_ERR_BADSTATE,
360 * -FDT_ERR_BADSTRUCTURE,
361 * -FDT_ERR_TRUNCATED, standard meanings.
362 */
363int fdt_first_property_offset(const void *fdt, int nodeoffset);
364
365/**
366 * fdt_next_property_offset - step through a node's properties
367 * @fdt: pointer to the device tree blob
368 * @offset: structure block offset of a property
369 *
370 * fdt_next_property_offset() finds the property immediately after the
371 * one at the given structure block offset. This will be a property
372 * of the same node as the given property.
373 *
374 * returns:
375 * structure block offset of the next property (>=0), on success
376 * -FDT_ERR_NOTFOUND, if the given property is the last in its node
377 * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
378 * -FDT_ERR_BADMAGIC,
379 * -FDT_ERR_BADVERSION,
380 * -FDT_ERR_BADSTATE,
381 * -FDT_ERR_BADSTRUCTURE,
382 * -FDT_ERR_TRUNCATED, standard meanings.
383 */
384int fdt_next_property_offset(const void *fdt, int offset);
385
386/**
387 * fdt_get_property_by_offset - retrieve the property at a given offset
388 * @fdt: pointer to the device tree blob
389 * @offset: offset of the property to retrieve
390 * @lenp: pointer to an integer variable (will be overwritten) or NULL
391 *
392 * fdt_get_property_by_offset() retrieves a pointer to the
393 * fdt_property structure within the device tree blob at the given
394 * offset. If lenp is non-NULL, the length of the property value is
395 * also returned, in the integer pointed to by lenp.
396 *
397 * returns:
398 * pointer to the structure representing the property
399 * if lenp is non-NULL, *lenp contains the length of the property
400 * value (>=0)
401 * NULL, on error
402 * if lenp is non-NULL, *lenp contains an error code (<0):
403 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
404 * -FDT_ERR_BADMAGIC,
405 * -FDT_ERR_BADVERSION,
406 * -FDT_ERR_BADSTATE,
407 * -FDT_ERR_BADSTRUCTURE,
408 * -FDT_ERR_TRUNCATED, standard meanings
409 */
410const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
411 int offset,
412 int *lenp);
413
414/**
415 * fdt_get_property_namelen - find a property based on substring
416 * @fdt: pointer to the device tree blob
417 * @nodeoffset: offset of the node whose property to find
418 * @name: name of the property to find
419 * @namelen: number of characters of name to consider
420 * @lenp: pointer to an integer variable (will be overwritten) or NULL
421 *
422 * Identical to fdt_get_property_namelen(), but only examine the first
423 * namelen characters of name for matching the property name.
424 */
425const struct fdt_property *fdt_get_property_namelen(const void *fdt,
426 int nodeoffset,
427 const char *name,
428 int namelen, int *lenp);
429
430/**
346 * fdt_get_property - find a given property in a given node 431 * fdt_get_property - find a given property in a given node
347 * @fdt: pointer to the device tree blob 432 * @fdt: pointer to the device tree blob
348 * @nodeoffset: offset of the node whose property to find 433 * @nodeoffset: offset of the node whose property to find
@@ -380,6 +465,54 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
380} 465}
381 466
382/** 467/**
468 * fdt_getprop_by_offset - retrieve the value of a property at a given offset
469 * @fdt: pointer to the device tree blob
470 * @ffset: offset of the property to read
471 * @namep: pointer to a string variable (will be overwritten) or NULL
472 * @lenp: pointer to an integer variable (will be overwritten) or NULL
473 *
474 * fdt_getprop_by_offset() retrieves a pointer to the value of the
475 * property at structure block offset 'offset' (this will be a pointer
476 * to within the device blob itself, not a copy of the value). If
477 * lenp is non-NULL, the length of the property value is also
478 * returned, in the integer pointed to by lenp. If namep is non-NULL,
479 * the property's namne will also be returned in the char * pointed to
480 * by namep (this will be a pointer to within the device tree's string
481 * block, not a new copy of the name).
482 *
483 * returns:
484 * pointer to the property's value
485 * if lenp is non-NULL, *lenp contains the length of the property
486 * value (>=0)
487 * if namep is non-NULL *namep contiains a pointer to the property
488 * name.
489 * NULL, on error
490 * if lenp is non-NULL, *lenp contains an error code (<0):
491 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
492 * -FDT_ERR_BADMAGIC,
493 * -FDT_ERR_BADVERSION,
494 * -FDT_ERR_BADSTATE,
495 * -FDT_ERR_BADSTRUCTURE,
496 * -FDT_ERR_TRUNCATED, standard meanings
497 */
498const void *fdt_getprop_by_offset(const void *fdt, int offset,
499 const char **namep, int *lenp);
500
501/**
502 * fdt_getprop_namelen - get property value based on substring
503 * @fdt: pointer to the device tree blob
504 * @nodeoffset: offset of the node whose property to find
505 * @name: name of the property to find
506 * @namelen: number of characters of name to consider
507 * @lenp: pointer to an integer variable (will be overwritten) or NULL
508 *
509 * Identical to fdt_getprop(), but only examine the first namelen
510 * characters of name for matching the property name.
511 */
512const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
513 const char *name, int namelen, int *lenp);
514
515/**
383 * fdt_getprop - retrieve the value of a given property 516 * fdt_getprop - retrieve the value of a given property
384 * @fdt: pointer to the device tree blob 517 * @fdt: pointer to the device tree blob
385 * @nodeoffset: offset of the node whose property to find 518 * @nodeoffset: offset of the node whose property to find
@@ -429,6 +562,32 @@ static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
429uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); 562uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
430 563
431/** 564/**
565 * fdt_get_alias_namelen - get alias based on substring
566 * @fdt: pointer to the device tree blob
567 * @name: name of the alias th look up
568 * @namelen: number of characters of name to consider
569 *
570 * Identical to fdt_get_alias(), but only examine the first namelen
571 * characters of name for matching the alias name.
572 */
573const char *fdt_get_alias_namelen(const void *fdt,
574 const char *name, int namelen);
575
576/**
577 * fdt_get_alias - retreive the path referenced by a given alias
578 * @fdt: pointer to the device tree blob
579 * @name: name of the alias th look up
580 *
581 * fdt_get_alias() retrieves the value of a given alias. That is, the
582 * value of the property named 'name' in the node /aliases.
583 *
584 * returns:
585 * a pointer to the expansion of the alias named 'name', of it exists
586 * NULL, if the given alias or the /aliases node does not exist
587 */
588const char *fdt_get_alias(const void *fdt, const char *name);
589
590/**
432 * fdt_get_path - determine the full path of a node 591 * fdt_get_path - determine the full path of a node
433 * @fdt: pointer to the device tree blob 592 * @fdt: pointer to the device tree blob
434 * @nodeoffset: offset of the node whose path to find 593 * @nodeoffset: offset of the node whose path to find
@@ -693,17 +852,17 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
693 const void *val, int len); 852 const void *val, int len);
694 853
695/** 854/**
696 * fdt_setprop_inplace_cell - change the value of a single-cell property 855 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
697 * @fdt: pointer to the device tree blob 856 * @fdt: pointer to the device tree blob
698 * @nodeoffset: offset of the node whose property to change 857 * @nodeoffset: offset of the node whose property to change
699 * @name: name of the property to change 858 * @name: name of the property to change
700 * @val: cell (32-bit integer) value to replace the property with 859 * @val: 32-bit integer value to replace the property with
701 * 860 *
702 * fdt_setprop_inplace_cell() replaces the value of a given property 861 * fdt_setprop_inplace_u32() replaces the value of a given property
703 * with the 32-bit integer cell value in val, converting val to 862 * with the 32-bit integer value in val, converting val to big-endian
704 * big-endian if necessary. This function cannot change the size of a 863 * if necessary. This function cannot change the size of a property,
705 * property, and so will only work if the property already exists and 864 * and so will only work if the property already exists and has length
706 * has length 4. 865 * 4.
707 * 866 *
708 * This function will alter only the bytes in the blob which contain 867 * This function will alter only the bytes in the blob which contain
709 * the given property value, and will not alter or move any other part 868 * the given property value, and will not alter or move any other part
@@ -712,7 +871,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
712 * returns: 871 * returns:
713 * 0, on success 872 * 0, on success
714 * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 873 * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
715 * -FDT_ERR_NOTFOUND, node does not have the named property 874 * -FDT_ERR_NOTFOUND, node does not have the named property
716 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 875 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
717 * -FDT_ERR_BADMAGIC, 876 * -FDT_ERR_BADMAGIC,
718 * -FDT_ERR_BADVERSION, 877 * -FDT_ERR_BADVERSION,
@@ -720,14 +879,60 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
720 * -FDT_ERR_BADSTRUCTURE, 879 * -FDT_ERR_BADSTRUCTURE,
721 * -FDT_ERR_TRUNCATED, standard meanings 880 * -FDT_ERR_TRUNCATED, standard meanings
722 */ 881 */
723static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, 882static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
724 const char *name, uint32_t val) 883 const char *name, uint32_t val)
725{ 884{
726 val = cpu_to_fdt32(val); 885 val = cpu_to_fdt32(val);
727 return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); 886 return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
728} 887}
729 888
730/** 889/**
890 * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property
891 * @fdt: pointer to the device tree blob
892 * @nodeoffset: offset of the node whose property to change
893 * @name: name of the property to change
894 * @val: 64-bit integer value to replace the property with
895 *
896 * fdt_setprop_inplace_u64() replaces the value of a given property
897 * with the 64-bit integer value in val, converting val to big-endian
898 * if necessary. This function cannot change the size of a property,
899 * and so will only work if the property already exists and has length
900 * 8.
901 *
902 * This function will alter only the bytes in the blob which contain
903 * the given property value, and will not alter or move any other part
904 * of the tree.
905 *
906 * returns:
907 * 0, on success
908 * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
909 * -FDT_ERR_NOTFOUND, node does not have the named property
910 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
911 * -FDT_ERR_BADMAGIC,
912 * -FDT_ERR_BADVERSION,
913 * -FDT_ERR_BADSTATE,
914 * -FDT_ERR_BADSTRUCTURE,
915 * -FDT_ERR_TRUNCATED, standard meanings
916 */
917static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
918 const char *name, uint64_t val)
919{
920 val = cpu_to_fdt64(val);
921 return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
922}
923
924/**
925 * fdt_setprop_inplace_cell - change the value of a single-cell property
926 *
927 * This is an alternative name for fdt_setprop_inplace_u32()
928 */
929static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
930 const char *name, uint32_t val)
931{
932 return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
933}
934
935/**
731 * fdt_nop_property - replace a property with nop tags 936 * fdt_nop_property - replace a property with nop tags
732 * @fdt: pointer to the device tree blob 937 * @fdt: pointer to the device tree blob
733 * @nodeoffset: offset of the node whose property to nop 938 * @nodeoffset: offset of the node whose property to nop
@@ -786,11 +991,20 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
786int fdt_finish_reservemap(void *fdt); 991int fdt_finish_reservemap(void *fdt);
787int fdt_begin_node(void *fdt, const char *name); 992int fdt_begin_node(void *fdt, const char *name);
788int fdt_property(void *fdt, const char *name, const void *val, int len); 993int fdt_property(void *fdt, const char *name, const void *val, int len);
789static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) 994static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
790{ 995{
791 val = cpu_to_fdt32(val); 996 val = cpu_to_fdt32(val);
792 return fdt_property(fdt, name, &val, sizeof(val)); 997 return fdt_property(fdt, name, &val, sizeof(val));
793} 998}
999static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
1000{
1001 val = cpu_to_fdt64(val);
1002 return fdt_property(fdt, name, &val, sizeof(val));
1003}
1004static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
1005{
1006 return fdt_property_u32(fdt, name, val);
1007}
794#define fdt_property_string(fdt, name, str) \ 1008#define fdt_property_string(fdt, name, str) \
795 fdt_property(fdt, name, str, strlen(str)+1) 1009 fdt_property(fdt, name, str, strlen(str)+1)
796int fdt_end_node(void *fdt); 1010int fdt_end_node(void *fdt);
@@ -800,6 +1014,7 @@ int fdt_finish(void *fdt);
800/* Read-write functions */ 1014/* Read-write functions */
801/**********************************************************************/ 1015/**********************************************************************/
802 1016
1017int fdt_create_empty_tree(void *buf, int bufsize);
803int fdt_open_into(const void *fdt, void *buf, int bufsize); 1018int fdt_open_into(const void *fdt, void *buf, int bufsize);
804int fdt_pack(void *fdt); 1019int fdt_pack(void *fdt);
805 1020
@@ -909,14 +1124,14 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
909 const void *val, int len); 1124 const void *val, int len);
910 1125
911/** 1126/**
912 * fdt_setprop_cell - set a property to a single cell value 1127 * fdt_setprop_u32 - set a property to a 32-bit integer
913 * @fdt: pointer to the device tree blob 1128 * @fdt: pointer to the device tree blob
914 * @nodeoffset: offset of the node whose property to change 1129 * @nodeoffset: offset of the node whose property to change
915 * @name: name of the property to change 1130 * @name: name of the property to change
916 * @val: 32-bit integer value for the property (native endian) 1131 * @val: 32-bit integer value for the property (native endian)
917 * 1132 *
918 * fdt_setprop_cell() sets the value of the named property in the 1133 * fdt_setprop_u32() sets the value of the named property in the given
919 * given node to the given cell value (converting to big-endian if 1134 * node to the given 32-bit integer value (converting to big-endian if
920 * necessary), or creates a new property with that value if it does 1135 * necessary), or creates a new property with that value if it does
921 * not already exist. 1136 * not already exist.
922 * 1137 *
@@ -936,14 +1151,60 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
936 * -FDT_ERR_BADLAYOUT, 1151 * -FDT_ERR_BADLAYOUT,
937 * -FDT_ERR_TRUNCATED, standard meanings 1152 * -FDT_ERR_TRUNCATED, standard meanings
938 */ 1153 */
939static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, 1154static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
940 uint32_t val) 1155 uint32_t val)
941{ 1156{
942 val = cpu_to_fdt32(val); 1157 val = cpu_to_fdt32(val);
943 return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); 1158 return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
944} 1159}
945 1160
946/** 1161/**
1162 * fdt_setprop_u64 - set a property to a 64-bit integer
1163 * @fdt: pointer to the device tree blob
1164 * @nodeoffset: offset of the node whose property to change
1165 * @name: name of the property to change
1166 * @val: 64-bit integer value for the property (native endian)
1167 *
1168 * fdt_setprop_u64() sets the value of the named property in the given
1169 * node to the given 64-bit integer value (converting to big-endian if
1170 * necessary), or creates a new property with that value if it does
1171 * not already exist.
1172 *
1173 * This function may insert or delete data from the blob, and will
1174 * therefore change the offsets of some existing nodes.
1175 *
1176 * returns:
1177 * 0, on success
1178 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1179 * contain the new property value
1180 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1181 * -FDT_ERR_BADLAYOUT,
1182 * -FDT_ERR_BADMAGIC,
1183 * -FDT_ERR_BADVERSION,
1184 * -FDT_ERR_BADSTATE,
1185 * -FDT_ERR_BADSTRUCTURE,
1186 * -FDT_ERR_BADLAYOUT,
1187 * -FDT_ERR_TRUNCATED, standard meanings
1188 */
1189static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
1190 uint64_t val)
1191{
1192 val = cpu_to_fdt64(val);
1193 return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
1194}
1195
1196/**
1197 * fdt_setprop_cell - set a property to a single cell value
1198 *
1199 * This is an alternative name for fdt_setprop_u32()
1200 */
1201static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
1202 uint32_t val)
1203{
1204 return fdt_setprop_u32(fdt, nodeoffset, name, val);
1205}
1206
1207/**
947 * fdt_setprop_string - set a property to a string value 1208 * fdt_setprop_string - set a property to a string value
948 * @fdt: pointer to the device tree blob 1209 * @fdt: pointer to the device tree blob
949 * @nodeoffset: offset of the node whose property to change 1210 * @nodeoffset: offset of the node whose property to change
@@ -975,6 +1236,147 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
975 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1236 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
976 1237
977/** 1238/**
1239 * fdt_appendprop - append to or create a property
1240 * @fdt: pointer to the device tree blob
1241 * @nodeoffset: offset of the node whose property to change
1242 * @name: name of the property to append to
1243 * @val: pointer to data to append to the property value
1244 * @len: length of the data to append to the property value
1245 *
1246 * fdt_appendprop() appends the value to the named property in the
1247 * given node, creating the property if it does not already exist.
1248 *
1249 * This function may insert data into the blob, and will therefore
1250 * change the offsets of some existing nodes.
1251 *
1252 * returns:
1253 * 0, on success
1254 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1255 * contain the new property value
1256 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1257 * -FDT_ERR_BADLAYOUT,
1258 * -FDT_ERR_BADMAGIC,
1259 * -FDT_ERR_BADVERSION,
1260 * -FDT_ERR_BADSTATE,
1261 * -FDT_ERR_BADSTRUCTURE,
1262 * -FDT_ERR_BADLAYOUT,
1263 * -FDT_ERR_TRUNCATED, standard meanings
1264 */
1265int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
1266 const void *val, int len);
1267
1268/**
1269 * fdt_appendprop_u32 - append a 32-bit integer value to a property
1270 * @fdt: pointer to the device tree blob
1271 * @nodeoffset: offset of the node whose property to change
1272 * @name: name of the property to change
1273 * @val: 32-bit integer value to append to the property (native endian)
1274 *
1275 * fdt_appendprop_u32() appends the given 32-bit integer value
1276 * (converting to big-endian if necessary) to the value of the named
1277 * property in the given node, or creates a new property with that
1278 * value if it does not already exist.
1279 *
1280 * This function may insert data into the blob, and will therefore
1281 * change the offsets of some existing nodes.
1282 *
1283 * returns:
1284 * 0, on success
1285 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1286 * contain the new property value
1287 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1288 * -FDT_ERR_BADLAYOUT,
1289 * -FDT_ERR_BADMAGIC,
1290 * -FDT_ERR_BADVERSION,
1291 * -FDT_ERR_BADSTATE,
1292 * -FDT_ERR_BADSTRUCTURE,
1293 * -FDT_ERR_BADLAYOUT,
1294 * -FDT_ERR_TRUNCATED, standard meanings
1295 */
1296static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
1297 const char *name, uint32_t val)
1298{
1299 val = cpu_to_fdt32(val);
1300 return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
1301}
1302
1303/**
1304 * fdt_appendprop_u64 - append a 64-bit integer value to a property
1305 * @fdt: pointer to the device tree blob
1306 * @nodeoffset: offset of the node whose property to change
1307 * @name: name of the property to change
1308 * @val: 64-bit integer value to append to the property (native endian)
1309 *
1310 * fdt_appendprop_u64() appends the given 64-bit integer value
1311 * (converting to big-endian if necessary) to the value of the named
1312 * property in the given node, or creates a new property with that
1313 * value if it does not already exist.
1314 *
1315 * This function may insert data into the blob, and will therefore
1316 * change the offsets of some existing nodes.
1317 *
1318 * returns:
1319 * 0, on success
1320 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1321 * contain the new property value
1322 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1323 * -FDT_ERR_BADLAYOUT,
1324 * -FDT_ERR_BADMAGIC,
1325 * -FDT_ERR_BADVERSION,
1326 * -FDT_ERR_BADSTATE,
1327 * -FDT_ERR_BADSTRUCTURE,
1328 * -FDT_ERR_BADLAYOUT,
1329 * -FDT_ERR_TRUNCATED, standard meanings
1330 */
1331static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
1332 const char *name, uint64_t val)
1333{
1334 val = cpu_to_fdt64(val);
1335 return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
1336}
1337
1338/**
1339 * fdt_appendprop_cell - append a single cell value to a property
1340 *
1341 * This is an alternative name for fdt_appendprop_u32()
1342 */
1343static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
1344 const char *name, uint32_t val)
1345{
1346 return fdt_appendprop_u32(fdt, nodeoffset, name, val);
1347}
1348
1349/**
1350 * fdt_appendprop_string - append a string to a property
1351 * @fdt: pointer to the device tree blob
1352 * @nodeoffset: offset of the node whose property to change
1353 * @name: name of the property to change
1354 * @str: string value to append to the property
1355 *
1356 * fdt_appendprop_string() appends the given string to the value of
1357 * the named property in the given node, or creates a new property
1358 * with that value if it does not already exist.
1359 *
1360 * This function may insert data into the blob, and will therefore
1361 * change the offsets of some existing nodes.
1362 *
1363 * returns:
1364 * 0, on success
1365 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1366 * contain the new property value
1367 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1368 * -FDT_ERR_BADLAYOUT,
1369 * -FDT_ERR_BADMAGIC,
1370 * -FDT_ERR_BADVERSION,
1371 * -FDT_ERR_BADSTATE,
1372 * -FDT_ERR_BADSTRUCTURE,
1373 * -FDT_ERR_BADLAYOUT,
1374 * -FDT_ERR_TRUNCATED, standard meanings
1375 */
1376#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
1377 fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1378
1379/**
978 * fdt_delprop - delete a property 1380 * fdt_delprop - delete a property
979 * @fdt: pointer to the device tree blob 1381 * @fdt: pointer to the device tree blob
980 * @nodeoffset: offset of the node whose property to nop 1382 * @nodeoffset: offset of the node whose property to nop