libfdt.h (204488) | libfdt.h (238742) |
---|---|
1#ifndef _LIBFDT_H 2#define _LIBFDT_H 3/* 4 * libfdt - Flat Device Tree manipulation 5 * Copyright (C) 2006 David Gibson, IBM Corporation. 6 * 7 * libfdt is dual licensed: you can use it either under the terms of 8 * the GPL, or the BSD license, at your option. --- 329 unchanged lines hidden (view full) --- 338 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 339 * -FDT_ERR_BADMAGIC, 340 * -FDT_ERR_BADVERSION, 341 * -FDT_ERR_BADSTATE, standard meanings 342 */ 343const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); 344 345/** | 1#ifndef _LIBFDT_H 2#define _LIBFDT_H 3/* 4 * libfdt - Flat Device Tree manipulation 5 * Copyright (C) 2006 David Gibson, IBM Corporation. 6 * 7 * libfdt is dual licensed: you can use it either under the terms of 8 * the GPL, or the BSD license, at your option. --- 329 unchanged lines hidden (view full) --- 338 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 339 * -FDT_ERR_BADMAGIC, 340 * -FDT_ERR_BADVERSION, 341 * -FDT_ERR_BADSTATE, standard meanings 342 */ 343const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); 344 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/** |
|
346 * fdt_get_property_namelen - find a property based on substring 347 * @fdt: pointer to the device tree blob 348 * @nodeoffset: offset of the node whose property to find 349 * @name: name of the property to find 350 * @namelen: number of characters of name to consider 351 * @lenp: pointer to an integer variable (will be overwritten) or NULL 352 * 353 * Identical to fdt_get_property_namelen(), but only examine the first --- 37 unchanged lines hidden (view full) --- 391 const char *name, 392 int *lenp) 393{ 394 return (struct fdt_property *)(uintptr_t) 395 fdt_get_property(fdt, nodeoffset, name, lenp); 396} 397 398/** | 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 --- 37 unchanged lines hidden (view full) --- 460 const char *name, 461 int *lenp) 462{ 463 return (struct fdt_property *)(uintptr_t) 464 fdt_get_property(fdt, nodeoffset, name, lenp); 465} 466 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/** |
|
399 * fdt_getprop_namelen - get property value based on substring 400 * @fdt: pointer to the device tree blob 401 * @nodeoffset: offset of the node whose property to find 402 * @name: name of the property to find 403 * @namelen: number of characters of name to consider 404 * @lenp: pointer to an integer variable (will be overwritten) or NULL 405 * 406 * Identical to fdt_getprop(), but only examine the first namelen --- 337 unchanged lines hidden (view full) --- 744 * -FDT_ERR_BADSTATE, 745 * -FDT_ERR_BADSTRUCTURE, 746 * -FDT_ERR_TRUNCATED, standard meanings 747 */ 748int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 749 const void *val, int len); 750 751/** | 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 --- 337 unchanged lines hidden (view full) --- 847 * -FDT_ERR_BADSTATE, 848 * -FDT_ERR_BADSTRUCTURE, 849 * -FDT_ERR_TRUNCATED, standard meanings 850 */ 851int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 852 const void *val, int len); 853 854/** |
752 * 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 |
753 * @fdt: pointer to the device tree blob 754 * @nodeoffset: offset of the node whose property to change 755 * @name: name of the property to change | 856 * @fdt: pointer to the device tree blob 857 * @nodeoffset: offset of the node whose property to change 858 * @name: name of the property to change |
756 * @val: cell (32-bit integer) value to replace the property with | 859 * @val: 32-bit integer value to replace the property with |
757 * | 860 * |
758 * fdt_setprop_inplace_cell() replaces the value of a given property 759 * with the 32-bit integer cell value in val, converting val to 760 * big-endian if necessary. This function cannot change the size of a 761 * property, and so will only work if the property already exists and 762 * has length 4. | 861 * fdt_setprop_inplace_u32() replaces the value of a given property 862 * with the 32-bit integer value in val, converting val to big-endian 863 * if necessary. This function cannot change the size of a property, 864 * and so will only work if the property already exists and has length 865 * 4. |
763 * 764 * This function will alter only the bytes in the blob which contain 765 * the given property value, and will not alter or move any other part 766 * of the tree. 767 * 768 * returns: 769 * 0, on success 770 * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 | 866 * 867 * This function will alter only the bytes in the blob which contain 868 * the given property value, and will not alter or move any other part 869 * of the tree. 870 * 871 * returns: 872 * 0, on success 873 * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 |
771 * -FDT_ERR_NOTFOUND, node does not have the named property | 874 * -FDT_ERR_NOTFOUND, node does not have the named property |
772 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 773 * -FDT_ERR_BADMAGIC, 774 * -FDT_ERR_BADVERSION, 775 * -FDT_ERR_BADSTATE, 776 * -FDT_ERR_BADSTRUCTURE, 777 * -FDT_ERR_TRUNCATED, standard meanings 778 */ | 875 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 876 * -FDT_ERR_BADMAGIC, 877 * -FDT_ERR_BADVERSION, 878 * -FDT_ERR_BADSTATE, 879 * -FDT_ERR_BADSTRUCTURE, 880 * -FDT_ERR_TRUNCATED, standard meanings 881 */ |
779static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, 780 const char *name, uint32_t val) | 882static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, 883 const char *name, uint32_t val) |
781{ 782 val = cpu_to_fdt32(val); 783 return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); 784} 785 786/** | 884{ 885 val = cpu_to_fdt32(val); 886 return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); 887} 888 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/** |
|
787 * fdt_nop_property - replace a property with nop tags 788 * @fdt: pointer to the device tree blob 789 * @nodeoffset: offset of the node whose property to nop 790 * @name: name of the property to nop 791 * 792 * fdt_nop_property() will replace a given property's representation 793 * in the blob with FDT_NOP tags, effectively removing it from the 794 * tree. --- 42 unchanged lines hidden (view full) --- 837/* Sequential write functions */ 838/**********************************************************************/ 839 840int fdt_create(void *buf, int bufsize); 841int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); 842int fdt_finish_reservemap(void *fdt); 843int fdt_begin_node(void *fdt, const char *name); 844int fdt_property(void *fdt, const char *name, const void *val, int len); | 936 * fdt_nop_property - replace a property with nop tags 937 * @fdt: pointer to the device tree blob 938 * @nodeoffset: offset of the node whose property to nop 939 * @name: name of the property to nop 940 * 941 * fdt_nop_property() will replace a given property's representation 942 * in the blob with FDT_NOP tags, effectively removing it from the 943 * tree. --- 42 unchanged lines hidden (view full) --- 986/* Sequential write functions */ 987/**********************************************************************/ 988 989int fdt_create(void *buf, int bufsize); 990int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); 991int fdt_finish_reservemap(void *fdt); 992int fdt_begin_node(void *fdt, const char *name); 993int fdt_property(void *fdt, const char *name, const void *val, int len); |
845static 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) |
846{ 847 val = cpu_to_fdt32(val); 848 return fdt_property(fdt, name, &val, sizeof(val)); 849} | 995{ 996 val = cpu_to_fdt32(val); 997 return fdt_property(fdt, name, &val, sizeof(val)); 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} |
|
850#define fdt_property_string(fdt, name, str) \ 851 fdt_property(fdt, name, str, strlen(str)+1) 852int fdt_end_node(void *fdt); 853int fdt_finish(void *fdt); 854 855/**********************************************************************/ 856/* Read-write functions */ 857/**********************************************************************/ 858 | 1008#define fdt_property_string(fdt, name, str) \ 1009 fdt_property(fdt, name, str, strlen(str)+1) 1010int fdt_end_node(void *fdt); 1011int fdt_finish(void *fdt); 1012 1013/**********************************************************************/ 1014/* Read-write functions */ 1015/**********************************************************************/ 1016 |
1017int fdt_create_empty_tree(void *buf, int bufsize); |
|
859int fdt_open_into(const void *fdt, void *buf, int bufsize); 860int fdt_pack(void *fdt); 861 862/** 863 * fdt_add_mem_rsv - add one memory reserve map entry 864 * @fdt: pointer to the device tree blob 865 * @address, @size: 64-bit values (native endian) 866 * --- 93 unchanged lines hidden (view full) --- 960 * -FDT_ERR_BADSTRUCTURE, 961 * -FDT_ERR_BADLAYOUT, 962 * -FDT_ERR_TRUNCATED, standard meanings 963 */ 964int fdt_setprop(void *fdt, int nodeoffset, const char *name, 965 const void *val, int len); 966 967/** | 1018int fdt_open_into(const void *fdt, void *buf, int bufsize); 1019int fdt_pack(void *fdt); 1020 1021/** 1022 * fdt_add_mem_rsv - add one memory reserve map entry 1023 * @fdt: pointer to the device tree blob 1024 * @address, @size: 64-bit values (native endian) 1025 * --- 93 unchanged lines hidden (view full) --- 1119 * -FDT_ERR_BADSTRUCTURE, 1120 * -FDT_ERR_BADLAYOUT, 1121 * -FDT_ERR_TRUNCATED, standard meanings 1122 */ 1123int fdt_setprop(void *fdt, int nodeoffset, const char *name, 1124 const void *val, int len); 1125 1126/** |
968 * fdt_setprop_cell - set a property to a single cell value | 1127 * fdt_setprop_u32 - set a property to a 32-bit integer |
969 * @fdt: pointer to the device tree blob 970 * @nodeoffset: offset of the node whose property to change 971 * @name: name of the property to change 972 * @val: 32-bit integer value for the property (native endian) 973 * | 1128 * @fdt: pointer to the device tree blob 1129 * @nodeoffset: offset of the node whose property to change 1130 * @name: name of the property to change 1131 * @val: 32-bit integer value for the property (native endian) 1132 * |
974 * fdt_setprop_cell() sets the value of the named property in the 975 * given node to the given cell value (converting to big-endian if | 1133 * fdt_setprop_u32() sets the value of the named property in the given 1134 * node to the given 32-bit integer value (converting to big-endian if |
976 * necessary), or creates a new property with that value if it does 977 * not already exist. 978 * 979 * This function may insert or delete data from the blob, and will 980 * therefore change the offsets of some existing nodes. 981 * 982 * returns: 983 * 0, on success 984 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 985 * contain the new property value 986 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 987 * -FDT_ERR_BADLAYOUT, 988 * -FDT_ERR_BADMAGIC, 989 * -FDT_ERR_BADVERSION, 990 * -FDT_ERR_BADSTATE, 991 * -FDT_ERR_BADSTRUCTURE, 992 * -FDT_ERR_BADLAYOUT, 993 * -FDT_ERR_TRUNCATED, standard meanings 994 */ | 1135 * necessary), or creates a new property with that value if it does 1136 * not already exist. 1137 * 1138 * This function may insert or delete data from the blob, and will 1139 * therefore change the offsets of some existing nodes. 1140 * 1141 * returns: 1142 * 0, on success 1143 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1144 * contain the new property value 1145 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1146 * -FDT_ERR_BADLAYOUT, 1147 * -FDT_ERR_BADMAGIC, 1148 * -FDT_ERR_BADVERSION, 1149 * -FDT_ERR_BADSTATE, 1150 * -FDT_ERR_BADSTRUCTURE, 1151 * -FDT_ERR_BADLAYOUT, 1152 * -FDT_ERR_TRUNCATED, standard meanings 1153 */ |
995static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, 996 uint32_t val) | 1154static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, 1155 uint32_t val) |
997{ 998 val = cpu_to_fdt32(val); 999 return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); 1000} 1001 1002/** | 1156{ 1157 val = cpu_to_fdt32(val); 1158 return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); 1159} 1160 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/** |
|
1003 * fdt_setprop_string - set a property to a string value 1004 * @fdt: pointer to the device tree blob 1005 * @nodeoffset: offset of the node whose property to change 1006 * @name: name of the property to change 1007 * @str: string value for the property 1008 * 1009 * fdt_setprop_string() sets the value of the named property in the 1010 * given node to the given string value (using the length of the --- 15 unchanged lines hidden (view full) --- 1026 * -FDT_ERR_BADSTRUCTURE, 1027 * -FDT_ERR_BADLAYOUT, 1028 * -FDT_ERR_TRUNCATED, standard meanings 1029 */ 1030#define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1031 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1032 1033/** | 1208 * fdt_setprop_string - set a property to a string value 1209 * @fdt: pointer to the device tree blob 1210 * @nodeoffset: offset of the node whose property to change 1211 * @name: name of the property to change 1212 * @str: string value for the property 1213 * 1214 * fdt_setprop_string() sets the value of the named property in the 1215 * given node to the given string value (using the length of the --- 15 unchanged lines hidden (view full) --- 1231 * -FDT_ERR_BADSTRUCTURE, 1232 * -FDT_ERR_BADLAYOUT, 1233 * -FDT_ERR_TRUNCATED, standard meanings 1234 */ 1235#define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1236 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1237 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/** |
|
1034 * fdt_delprop - delete a property 1035 * @fdt: pointer to the device tree blob 1036 * @nodeoffset: offset of the node whose property to nop 1037 * @name: name of the property to nop 1038 * 1039 * fdt_del_property() will delete the given property. 1040 * 1041 * This function will delete data from the blob, and will therefore --- 91 unchanged lines hidden --- | 1380 * fdt_delprop - delete a property 1381 * @fdt: pointer to the device tree blob 1382 * @nodeoffset: offset of the node whose property to nop 1383 * @name: name of the property to nop 1384 * 1385 * fdt_del_property() will delete the given property. 1386 * 1387 * This function will delete data from the blob, and will therefore --- 91 unchanged lines hidden --- |