Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/dtc: Update to upstream version v1.5.0-23-g87963ee20693

This adds the following commits from upstream:

87963ee20693 livetree: add missing type markers in generated overlay properties
825146d13dc0 Fix typos in various documentation and source files
25bb080c18d1 Update the GPL2 text to the latest revision
243176c4ce84 Fix bogus error on rebuild
ce01b21098a4 libfdt: Add FDT_CREATE_FLAG_NO_NAME_DEDUP flag that trades size for speed
fbb62754ce45 libfdt: Introduce fdt_create_with_flags()
228a44cce857 libfdt: Ensure fdt_add_property frees allocated name string on failure
8f695676227b Avoid assertion in check_interrupts_property()
5c3513f68921 Link tools and tests against libfdt shared library
00f9febf9c16 tests: Rename tests.sh to testutils.sh
c5d45188f923 Clean up LDLIBS handling
6ef8fcd05b74 Rebuild libfdt shared object if versioning linker script changes
26ee65a16c38 Use Python3 by default
cca6546244cb libfdt: Make fdt_get_max_phandle() an inline
730875016a6a libfdt: Add phandle generation helper
7dfb61ba96b1 libfdt: Use fdt_find_max_phandle()
2bc5b66d7f6c libfdt: Add new maximum phandle lookup function
7fcf8208b8a9 libfdt: add fdt_append_addrrange()
ae795b2db7a4 checks: Do not omit nodes with labels if symbol generation is requested
eac2ad495b29 Update version.lds again
f67b47135523 Revert "libfdt: Add phandle generation helper"
54ea41c22415 libfdt: Add phandle generation helper
4762ad051ee0 checks: Fix spelling in check_graph_endpoint
d37f6b20107e Bump version to v1.5.0
a4b1a307ff3a pylibfdt:tests: Extend the way how to find a Python module
625dd8aaf20f pylibfdt: Change how passing tests are recognized
364631626bb7 pylibfdt: Test fdt.setprop take bytes on Python 3, add error handling
cb0f454f73cc pylibfdt: check_err accepts only integer as a first argument.
4b68c6b3605a pylibfdt: Proper handling of bytes/unicode strings and octal literals
78e113e81c9d Use PRIxPTR for printing uintptr_t values
ea7a8f6dad67 libfdt: Fix FDT_ERR_NOTFOUND typos in documentation
5aafd7ca43e0 libfdt: Fix fdt_getprop_by_offset() parameter name in documentation
7cbc550f903b checks: Add unit address check if node is enabled

Signed-off-by: Rob Herring <robh@kernel.org>

+399 -56
+49 -6
scripts/dtc/checks.c
··· 660 660 static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti, 661 661 struct node *node) 662 662 { 663 + if (generate_symbols && node->labels) 664 + return; 663 665 if (node->omit_if_unused && !node->is_referenced) 664 666 delete_node(node); 665 667 } ··· 1214 1212 } 1215 1213 WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size); 1216 1214 1217 - static void check_unique_unit_address(struct check *c, struct dt_info *dti, 1218 - struct node *node) 1215 + static bool node_is_disabled(struct node *node) 1216 + { 1217 + struct property *prop; 1218 + 1219 + prop = get_property(node, "status"); 1220 + if (prop) { 1221 + char *str = prop->val.val; 1222 + if (streq("disabled", str)) 1223 + return true; 1224 + } 1225 + 1226 + return false; 1227 + } 1228 + 1229 + static void check_unique_unit_address_common(struct check *c, 1230 + struct dt_info *dti, 1231 + struct node *node, 1232 + bool disable_check) 1219 1233 { 1220 1234 struct node *childa; 1221 1235 ··· 1248 1230 if (!strlen(addr_a)) 1249 1231 continue; 1250 1232 1233 + if (disable_check && node_is_disabled(childa)) 1234 + continue; 1235 + 1251 1236 for_each_child(node, childb) { 1252 1237 const char *addr_b = get_unitname(childb); 1253 1238 if (childa == childb) 1254 1239 break; 1240 + 1241 + if (disable_check && node_is_disabled(childb)) 1242 + continue; 1255 1243 1256 1244 if (streq(addr_a, addr_b)) 1257 1245 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath); 1258 1246 } 1259 1247 } 1260 1248 } 1249 + 1250 + static void check_unique_unit_address(struct check *c, struct dt_info *dti, 1251 + struct node *node) 1252 + { 1253 + check_unique_unit_address_common(c, dti, node, false); 1254 + } 1261 1255 WARNING(unique_unit_address, check_unique_unit_address, NULL, &avoid_default_addr_size); 1256 + 1257 + static void check_unique_unit_address_if_enabled(struct check *c, struct dt_info *dti, 1258 + struct node *node) 1259 + { 1260 + check_unique_unit_address_common(c, dti, node, true); 1261 + } 1262 + CHECK_ENTRY(unique_unit_address_if_enabled, check_unique_unit_address_if_enabled, 1263 + NULL, false, false, &avoid_default_addr_size); 1262 1264 1263 1265 static void check_obsolete_chosen_interrupt_controller(struct check *c, 1264 1266 struct dt_info *dti, ··· 1580 1542 prop = get_property(parent, "interrupt-parent"); 1581 1543 if (prop) { 1582 1544 phandle = propval_cell(prop); 1583 - /* Give up if this is an overlay with external references */ 1584 - if ((phandle == 0 || phandle == -1) && 1585 - (dti->dtsflags & DTSF_PLUGIN)) 1545 + if ((phandle == 0) || (phandle == -1)) { 1546 + /* Give up if this is an overlay with 1547 + * external references */ 1548 + if (dti->dtsflags & DTSF_PLUGIN) 1586 1549 return; 1550 + FAIL_PROP(c, dti, parent, prop, "Invalid phandle"); 1551 + continue; 1552 + } 1587 1553 1588 1554 irq_node = get_node_by_phandle(root, phandle); 1589 1555 if (!irq_node) { ··· 1756 1714 return; 1757 1715 1758 1716 if (!strprefixeq(node->name, node->basenamelen, "endpoint")) 1759 - FAIL(c, dti, node, "graph endpont node name should be 'endpoint'"); 1717 + FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'"); 1760 1718 1761 1719 check_graph_reg(c, dti, node); 1762 1720 ··· 1811 1769 &avoid_default_addr_size, 1812 1770 &avoid_unnecessary_addr_size, 1813 1771 &unique_unit_address, 1772 + &unique_unit_address_if_enabled, 1814 1773 &obsolete_chosen_interrupt_controller, 1815 1774 &chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path, 1816 1775
+2 -1
scripts/dtc/dtc.h
··· 231 231 void delete_node_by_name(struct node *parent, char *name); 232 232 void delete_node(struct node *node); 233 233 void append_to_property(struct node *node, 234 - char *name, const void *data, int len); 234 + char *name, const void *data, int len, 235 + enum markertype type); 235 236 236 237 const char *get_unitname(struct node *node); 237 238 struct property *get_property(struct node *node, const char *propname);
+1 -1
scripts/dtc/flattree.c
··· 525 525 fprintf(f, "/* Memory reserve map from source file */\n"); 526 526 527 527 /* 528 - * Use .long on high and low halfs of u64s to avoid .quad 528 + * Use .long on high and low halves of u64s to avoid .quad 529 529 * as it appears .quad isn't available in some assemblers. 530 530 */ 531 531 for (re = dti->reservelist; re; re = re->next) {
+2
scripts/dtc/libfdt/Makefile.libfdt
··· 9 9 LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \ 10 10 fdt_addresses.c fdt_overlay.c 11 11 LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) 12 + LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) 12 13 13 14 libfdt_clean: 14 15 @$(VECHO) CLEAN "(libfdt)" 15 16 rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%) 17 + rm -f $(LIBFDT_dir)/$(LIBFDT_soname)
+47
scripts/dtc/libfdt/fdt_addresses.c
··· 95 95 return 1; 96 96 return val; 97 97 } 98 + 99 + /* This function assumes that [address|size]_cells is 1 or 2 */ 100 + int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset, 101 + const char *name, uint64_t addr, uint64_t size) 102 + { 103 + int addr_cells, size_cells, ret; 104 + uint8_t data[sizeof(fdt64_t) * 2], *prop; 105 + 106 + ret = fdt_address_cells(fdt, parent); 107 + if (ret < 0) 108 + return ret; 109 + addr_cells = ret; 110 + 111 + ret = fdt_size_cells(fdt, parent); 112 + if (ret < 0) 113 + return ret; 114 + size_cells = ret; 115 + 116 + /* check validity of address */ 117 + prop = data; 118 + if (addr_cells == 1) { 119 + if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size)) 120 + return -FDT_ERR_BADVALUE; 121 + 122 + fdt32_st(prop, (uint32_t)addr); 123 + } else if (addr_cells == 2) { 124 + fdt64_st(prop, addr); 125 + } else { 126 + return -FDT_ERR_BADNCELLS; 127 + } 128 + 129 + /* check validity of size */ 130 + prop += addr_cells * sizeof(fdt32_t); 131 + if (size_cells == 1) { 132 + if (size > UINT32_MAX) 133 + return -FDT_ERR_BADVALUE; 134 + 135 + fdt32_st(prop, (uint32_t)size); 136 + } else if (size_cells == 2) { 137 + fdt64_st(prop, size); 138 + } else { 139 + return -FDT_ERR_BADNCELLS; 140 + } 141 + 142 + return fdt_appendprop(fdt, nodeoffset, name, data, 143 + (addr_cells + size_cells) * sizeof(fdt32_t)); 144 + }
+7 -3
scripts/dtc/libfdt/fdt_overlay.c
··· 93 93 * @pathp: pointer which receives the path of the target (or NULL) 94 94 * 95 95 * overlay_get_target() retrieves the target offset in the base 96 - * device tree of a fragment, no matter how the actual targetting is 96 + * device tree of a fragment, no matter how the actual targeting is 97 97 * done (through a phandle or a path) 98 98 * 99 99 * returns: 100 - * the targetted node offset in the base device tree 100 + * the targeted node offset in the base device tree 101 101 * Negative error code on error 102 102 */ 103 103 static int overlay_get_target(const void *fdt, const void *fdto, ··· 863 863 864 864 int fdt_overlay_apply(void *fdt, void *fdto) 865 865 { 866 - uint32_t delta = fdt_get_max_phandle(fdt); 866 + uint32_t delta; 867 867 int ret; 868 868 869 869 FDT_RO_PROBE(fdt); 870 870 FDT_RO_PROBE(fdto); 871 + 872 + ret = fdt_find_max_phandle(fdt, &delta); 873 + if (ret) 874 + goto err; 871 875 872 876 ret = overlay_adjust_local_phandles(fdto, delta); 873 877 if (ret)
+35 -15
scripts/dtc/libfdt/fdt_ro.c
··· 144 144 return p && (slen == len) && (memcmp(p, s, len) == 0); 145 145 } 146 146 147 - uint32_t fdt_get_max_phandle(const void *fdt) 147 + int fdt_find_max_phandle(const void *fdt, uint32_t *phandle) 148 148 { 149 - uint32_t max_phandle = 0; 150 - int offset; 149 + uint32_t max = 0; 150 + int offset = -1; 151 151 152 - for (offset = fdt_next_node(fdt, -1, NULL);; 153 - offset = fdt_next_node(fdt, offset, NULL)) { 154 - uint32_t phandle; 152 + while (true) { 153 + uint32_t value; 155 154 156 - if (offset == -FDT_ERR_NOTFOUND) 157 - return max_phandle; 155 + offset = fdt_next_node(fdt, offset, NULL); 156 + if (offset < 0) { 157 + if (offset == -FDT_ERR_NOTFOUND) 158 + break; 158 159 159 - if (offset < 0) 160 - return (uint32_t)-1; 160 + return offset; 161 + } 161 162 162 - phandle = fdt_get_phandle(fdt, offset); 163 - if (phandle == (uint32_t)-1) 164 - continue; 163 + value = fdt_get_phandle(fdt, offset); 165 164 166 - if (phandle > max_phandle) 167 - max_phandle = phandle; 165 + if (value > max) 166 + max = value; 168 167 } 168 + 169 + if (phandle) 170 + *phandle = max; 171 + 172 + return 0; 173 + } 174 + 175 + int fdt_generate_phandle(const void *fdt, uint32_t *phandle) 176 + { 177 + uint32_t max; 178 + int err; 179 + 180 + err = fdt_find_max_phandle(fdt, &max); 181 + if (err < 0) 182 + return err; 183 + 184 + if (max == FDT_MAX_PHANDLE) 185 + return -FDT_ERR_NOPHANDLES; 186 + 187 + if (phandle) 188 + *phandle = max + 1; 169 189 170 190 return 0; 171 191 }
+19 -3
scripts/dtc/libfdt/fdt_rw.c
··· 136 136 return 0; 137 137 } 138 138 139 + /* Must only be used to roll back in case of error */ 140 + static void fdt_del_last_string_(void *fdt, const char *s) 141 + { 142 + int newlen = strlen(s) + 1; 143 + 144 + fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) - newlen); 145 + } 146 + 139 147 static int fdt_splice_string_(void *fdt, int newlen) 140 148 { 141 149 void *p = (char *)fdt ··· 157 149 return 0; 158 150 } 159 151 160 - static int fdt_find_add_string_(void *fdt, const char *s) 152 + static int fdt_find_add_string_(void *fdt, const char *s, int *allocated) 161 153 { 162 154 char *strtab = (char *)fdt + fdt_off_dt_strings(fdt); 163 155 const char *p; 164 156 char *new; 165 157 int len = strlen(s) + 1; 166 158 int err; 159 + 160 + *allocated = 0; 167 161 168 162 p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s); 169 163 if (p) ··· 176 166 err = fdt_splice_string_(fdt, len); 177 167 if (err) 178 168 return err; 169 + 170 + *allocated = 1; 179 171 180 172 memcpy(new, s, len); 181 173 return (new - strtab); ··· 237 225 int nextoffset; 238 226 int namestroff; 239 227 int err; 228 + int allocated; 240 229 241 230 if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0) 242 231 return nextoffset; 243 232 244 - namestroff = fdt_find_add_string_(fdt, name); 233 + namestroff = fdt_find_add_string_(fdt, name, &allocated); 245 234 if (namestroff < 0) 246 235 return namestroff; 247 236 ··· 250 237 proplen = sizeof(**prop) + FDT_TAGALIGN(len); 251 238 252 239 err = fdt_splice_struct_(fdt, *prop, 0, proplen); 253 - if (err) 240 + if (err) { 241 + if (allocated) 242 + fdt_del_last_string_(fdt, name); 254 243 return err; 244 + } 255 245 256 246 (*prop)->tag = cpu_to_fdt32(FDT_PROP); 257 247 (*prop)->nameoff = cpu_to_fdt32(namestroff);
+1
scripts/dtc/libfdt/fdt_strerror.c
··· 82 82 FDT_ERRTABENT(FDT_ERR_BADVALUE), 83 83 FDT_ERRTABENT(FDT_ERR_BADOVERLAY), 84 84 FDT_ERRTABENT(FDT_ERR_NOPHANDLES), 85 + FDT_ERRTABENT(FDT_ERR_BADFLAGS), 85 86 }; 86 87 #define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) 87 88
+67 -11
scripts/dtc/libfdt/fdt_sw.c
··· 121 121 return err; \ 122 122 } 123 123 124 + static inline uint32_t sw_flags(void *fdt) 125 + { 126 + /* assert: (fdt_magic(fdt) == FDT_SW_MAGIC) */ 127 + return fdt_last_comp_version(fdt); 128 + } 129 + 124 130 /* 'complete' state: Enter this state after fdt_finish() 125 131 * 126 132 * Allowed functions: none ··· 147 141 return fdt_offset_ptr_w_(fdt, offset); 148 142 } 149 143 150 - int fdt_create(void *buf, int bufsize) 144 + int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags) 151 145 { 152 146 const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header), 153 147 sizeof(struct fdt_reserve_entry)); ··· 156 150 if (bufsize < hdrsize) 157 151 return -FDT_ERR_NOSPACE; 158 152 153 + if (flags & ~FDT_CREATE_FLAGS_ALL) 154 + return -FDT_ERR_BADFLAGS; 155 + 159 156 memset(buf, 0, bufsize); 160 157 158 + /* 159 + * magic and last_comp_version keep intermediate state during the fdt 160 + * creation process, which is replaced with the proper FDT format by 161 + * fdt_finish(). 162 + * 163 + * flags should be accessed with sw_flags(). 164 + */ 161 165 fdt_set_magic(fdt, FDT_SW_MAGIC); 162 166 fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION); 163 - fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); 167 + fdt_set_last_comp_version(fdt, flags); 168 + 164 169 fdt_set_totalsize(fdt, bufsize); 165 170 166 171 fdt_set_off_mem_rsvmap(fdt, hdrsize); ··· 179 162 fdt_set_off_dt_strings(fdt, 0); 180 163 181 164 return 0; 165 + } 166 + 167 + int fdt_create(void *buf, int bufsize) 168 + { 169 + return fdt_create_with_flags(buf, bufsize, 0); 182 170 } 183 171 184 172 int fdt_resize(void *fdt, void *buf, int bufsize) ··· 284 262 return 0; 285 263 } 286 264 287 - static int fdt_find_add_string_(void *fdt, const char *s) 265 + static int fdt_add_string_(void *fdt, const char *s) 288 266 { 289 267 char *strtab = (char *)fdt + fdt_totalsize(fdt); 290 - const char *p; 291 268 int strtabsize = fdt_size_dt_strings(fdt); 292 269 int len = strlen(s) + 1; 293 270 int struct_top, offset; 294 271 295 - p = fdt_find_string_(strtab - strtabsize, strtabsize, s); 296 - if (p) 297 - return p - strtab; 298 - 299 - /* Add it */ 300 272 offset = -strtabsize - len; 301 273 struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); 302 274 if (fdt_totalsize(fdt) + offset < struct_top) ··· 301 285 return offset; 302 286 } 303 287 288 + /* Must only be used to roll back in case of error */ 289 + static void fdt_del_last_string_(void *fdt, const char *s) 290 + { 291 + int strtabsize = fdt_size_dt_strings(fdt); 292 + int len = strlen(s) + 1; 293 + 294 + fdt_set_size_dt_strings(fdt, strtabsize - len); 295 + } 296 + 297 + static int fdt_find_add_string_(void *fdt, const char *s, int *allocated) 298 + { 299 + char *strtab = (char *)fdt + fdt_totalsize(fdt); 300 + int strtabsize = fdt_size_dt_strings(fdt); 301 + const char *p; 302 + 303 + *allocated = 0; 304 + 305 + p = fdt_find_string_(strtab - strtabsize, strtabsize, s); 306 + if (p) 307 + return p - strtab; 308 + 309 + *allocated = 1; 310 + 311 + return fdt_add_string_(fdt, s); 312 + } 313 + 304 314 int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) 305 315 { 306 316 struct fdt_property *prop; 307 317 int nameoff; 318 + int allocated; 308 319 309 320 FDT_SW_PROBE_STRUCT(fdt); 310 321 311 - nameoff = fdt_find_add_string_(fdt, name); 322 + /* String de-duplication can be slow, _NO_NAME_DEDUP skips it */ 323 + if (sw_flags(fdt) & FDT_CREATE_FLAG_NO_NAME_DEDUP) { 324 + allocated = 1; 325 + nameoff = fdt_add_string_(fdt, name); 326 + } else { 327 + nameoff = fdt_find_add_string_(fdt, name, &allocated); 328 + } 312 329 if (nameoff == 0) 313 330 return -FDT_ERR_NOSPACE; 314 331 315 332 prop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len)); 316 - if (! prop) 333 + if (! prop) { 334 + if (allocated) 335 + fdt_del_last_string_(fdt, name); 317 336 return -FDT_ERR_NOSPACE; 337 + } 318 338 319 339 prop->tag = cpu_to_fdt32(FDT_PROP); 320 340 prop->nameoff = cpu_to_fdt32(nameoff); ··· 412 360 413 361 /* Finally, adjust the header */ 414 362 fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); 363 + 364 + /* And fix up fields that were keeping intermediate state. */ 365 + fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); 415 366 fdt_set_magic(fdt, FDT_MAGIC); 367 + 416 368 return 0; 417 369 }
+153 -5
scripts/dtc/libfdt/libfdt.h
··· 138 138 /* FDT_ERR_NOPHANDLES: The device tree doesn't have any 139 139 * phandle available anymore without causing an overflow */ 140 140 141 - #define FDT_ERR_MAX 17 141 + #define FDT_ERR_BADFLAGS 18 142 + /* FDT_ERR_BADFLAGS: The function was passed a flags field that 143 + * contains invalid flags or an invalid combination of flags. */ 144 + 145 + #define FDT_ERR_MAX 18 146 + 147 + /* constants */ 148 + #define FDT_MAX_PHANDLE 0xfffffffe 149 + /* Valid values for phandles range from 1 to 2^32-2. */ 142 150 143 151 /**********************************************************************/ 144 152 /* Low-level functions (you probably don't need these) */ ··· 179 171 | bp[3]; 180 172 } 181 173 174 + static inline void fdt32_st(void *property, uint32_t value) 175 + { 176 + uint8_t *bp = property; 177 + 178 + bp[0] = value >> 24; 179 + bp[1] = (value >> 16) & 0xff; 180 + bp[2] = (value >> 8) & 0xff; 181 + bp[3] = value & 0xff; 182 + } 183 + 182 184 static inline uint64_t fdt64_ld(const fdt64_t *p) 183 185 { 184 186 const uint8_t *bp = (const uint8_t *)p; ··· 201 183 | ((uint64_t)bp[5] << 16) 202 184 | ((uint64_t)bp[6] << 8) 203 185 | bp[7]; 186 + } 187 + 188 + static inline void fdt64_st(void *property, uint64_t value) 189 + { 190 + uint8_t *bp = property; 191 + 192 + bp[0] = value >> 56; 193 + bp[1] = (value >> 48) & 0xff; 194 + bp[2] = (value >> 40) & 0xff; 195 + bp[3] = (value >> 32) & 0xff; 196 + bp[4] = (value >> 24) & 0xff; 197 + bp[5] = (value >> 16) & 0xff; 198 + bp[6] = (value >> 8) & 0xff; 199 + bp[7] = value & 0xff; 204 200 } 205 201 206 202 /**********************************************************************/ ··· 259 227 * ... 260 228 * } 261 229 * 262 - * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) { 230 + * if ((node < 0) && (node != -FDT_ERR_NOTFOUND)) { 263 231 * Error handling 264 232 * } 265 233 * ··· 394 362 const char *fdt_string(const void *fdt, int stroffset); 395 363 396 364 /** 365 + * fdt_find_max_phandle - find and return the highest phandle in a tree 366 + * @fdt: pointer to the device tree blob 367 + * @phandle: return location for the highest phandle value found in the tree 368 + * 369 + * fdt_find_max_phandle() finds the highest phandle value in the given device 370 + * tree. The value returned in @phandle is only valid if the function returns 371 + * success. 372 + * 373 + * returns: 374 + * 0 on success or a negative error code on failure 375 + */ 376 + int fdt_find_max_phandle(const void *fdt, uint32_t *phandle); 377 + 378 + /** 397 379 * fdt_get_max_phandle - retrieves the highest phandle in a tree 398 380 * @fdt: pointer to the device tree blob 399 381 * ··· 415 369 * device tree. This will ignore badly formatted phandles, or phandles 416 370 * with a value of 0 or -1. 417 371 * 372 + * This function is deprecated in favour of fdt_find_max_phandle(). 373 + * 418 374 * returns: 419 375 * the highest phandle on success 420 376 * 0, if no phandle was found in the device tree 421 377 * -1, if an error occurred 422 378 */ 423 - uint32_t fdt_get_max_phandle(const void *fdt); 379 + static inline uint32_t fdt_get_max_phandle(const void *fdt) 380 + { 381 + uint32_t phandle; 382 + int err; 383 + 384 + err = fdt_find_max_phandle(fdt, &phandle); 385 + if (err < 0) 386 + return (uint32_t)-1; 387 + 388 + return phandle; 389 + } 390 + 391 + /** 392 + * fdt_generate_phandle - return a new, unused phandle for a device tree blob 393 + * @fdt: pointer to the device tree blob 394 + * @phandle: return location for the new phandle 395 + * 396 + * Walks the device tree blob and looks for the highest phandle value. On 397 + * success, the new, unused phandle value (one higher than the previously 398 + * highest phandle value in the device tree blob) will be returned in the 399 + * @phandle parameter. 400 + * 401 + * Returns: 402 + * 0 on success or a negative error-code on failure 403 + */ 404 + int fdt_generate_phandle(const void *fdt, uint32_t *phandle); 424 405 425 406 /** 426 407 * fdt_num_mem_rsv - retrieve the number of memory reserve map entries ··· 639 566 * ... 640 567 * } 641 568 * 642 - * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) { 569 + * if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) { 643 570 * Error handling 644 571 * } 645 572 * ··· 742 669 /** 743 670 * fdt_getprop_by_offset - retrieve the value of a property at a given offset 744 671 * @fdt: pointer to the device tree blob 745 - * @ffset: offset of the property to read 672 + * @offset: offset of the property to read 746 673 * @namep: pointer to a string variable (will be overwritten) or NULL 747 674 * @lenp: pointer to an integer variable (will be overwritten) or NULL 748 675 * ··· 1433 1360 /* Sequential write functions */ 1434 1361 /**********************************************************************/ 1435 1362 1363 + /* fdt_create_with_flags flags */ 1364 + #define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1 1365 + /* FDT_CREATE_FLAG_NO_NAME_DEDUP: Do not try to de-duplicate property 1366 + * names in the fdt. This can result in faster creation times, but 1367 + * a larger fdt. */ 1368 + 1369 + #define FDT_CREATE_FLAGS_ALL (FDT_CREATE_FLAG_NO_NAME_DEDUP) 1370 + 1371 + /** 1372 + * fdt_create_with_flags - begin creation of a new fdt 1373 + * @fdt: pointer to memory allocated where fdt will be created 1374 + * @bufsize: size of the memory space at fdt 1375 + * @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0. 1376 + * 1377 + * fdt_create_with_flags() begins the process of creating a new fdt with 1378 + * the sequential write interface. 1379 + * 1380 + * fdt creation process must end with fdt_finished() to produce a valid fdt. 1381 + * 1382 + * returns: 1383 + * 0, on success 1384 + * -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt 1385 + * -FDT_ERR_BADFLAGS, flags is not valid 1386 + */ 1387 + int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags); 1388 + 1389 + /** 1390 + * fdt_create - begin creation of a new fdt 1391 + * @fdt: pointer to memory allocated where fdt will be created 1392 + * @bufsize: size of the memory space at fdt 1393 + * 1394 + * fdt_create() is equivalent to fdt_create_with_flags() with flags=0. 1395 + * 1396 + * returns: 1397 + * 0, on success 1398 + * -FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt 1399 + */ 1436 1400 int fdt_create(void *buf, int bufsize); 1401 + 1437 1402 int fdt_resize(void *fdt, void *buf, int bufsize); 1438 1403 int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); 1439 1404 int fdt_finish_reservemap(void *fdt); ··· 1941 1830 */ 1942 1831 #define fdt_appendprop_string(fdt, nodeoffset, name, str) \ 1943 1832 fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1833 + 1834 + /** 1835 + * fdt_appendprop_addrrange - append a address range property 1836 + * @fdt: pointer to the device tree blob 1837 + * @parent: offset of the parent node 1838 + * @nodeoffset: offset of the node to add a property at 1839 + * @name: name of property 1840 + * @addr: start address of a given range 1841 + * @size: size of a given range 1842 + * 1843 + * fdt_appendprop_addrrange() appends an address range value (start 1844 + * address and size) to the value of the named property in the given 1845 + * node, or creates a new property with that value if it does not 1846 + * already exist. 1847 + * If "name" is not specified, a default "reg" is used. 1848 + * Cell sizes are determined by parent's #address-cells and #size-cells. 1849 + * 1850 + * This function may insert data into the blob, and will therefore 1851 + * change the offsets of some existing nodes. 1852 + * 1853 + * returns: 1854 + * 0, on success 1855 + * -FDT_ERR_BADLAYOUT, 1856 + * -FDT_ERR_BADMAGIC, 1857 + * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid 1858 + * #address-cells property 1859 + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag 1860 + * -FDT_ERR_BADSTATE, 1861 + * -FDT_ERR_BADSTRUCTURE, 1862 + * -FDT_ERR_BADVERSION, 1863 + * -FDT_ERR_BADVALUE, addr or size doesn't fit to respective cells size 1864 + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to 1865 + * contain a new property 1866 + * -FDT_ERR_TRUNCATED, standard meanings 1867 + */ 1868 + int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset, 1869 + const char *name, uint64_t addr, uint64_t size); 1944 1870 1945 1871 /** 1946 1872 * fdt_delprop - delete a property
+1
scripts/dtc/libfdt/libfdt_env.h
··· 52 52 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 53 */ 54 54 55 + #include <stdbool.h> 55 56 #include <stddef.h> 56 57 #include <stdint.h> 57 58 #include <stdlib.h>
+12 -8
scripts/dtc/livetree.c
··· 249 249 char *name; 250 250 251 251 if (ref[0] == '/') { 252 + d = data_add_marker(d, TYPE_STRING, ref); 252 253 d = data_append_data(d, ref, strlen(ref) + 1); 253 254 254 255 p = build_property("target-path", d, NULL); ··· 351 350 } 352 351 353 352 void append_to_property(struct node *node, 354 - char *name, const void *data, int len) 353 + char *name, const void *data, int len, 354 + enum markertype type) 355 355 { 356 356 struct data d; 357 357 struct property *p; 358 358 359 359 p = get_property(node, name); 360 360 if (p) { 361 - d = data_append_data(p->val, data, len); 361 + d = data_add_marker(p->val, type, name); 362 + d = data_append_data(d, data, len); 362 363 p->val = d; 363 364 } else { 364 - d = data_append_data(empty_data, data, len); 365 + d = data_add_marker(empty_data, type, name); 366 + d = data_append_data(d, data, len); 365 367 p = build_property(name, d, NULL); 366 368 add_property(node, p); 367 369 } ··· 862 858 863 859 /* insert it */ 864 860 p = build_property(l->label, 865 - data_copy_mem(node->fullpath, 866 - strlen(node->fullpath) + 1), 861 + data_copy_escape_string(node->fullpath, 862 + strlen(node->fullpath)), 867 863 NULL); 868 864 add_property(an, p); 869 865 } ··· 914 910 915 911 xasprintf(&entry, "%s:%s:%u", 916 912 node->fullpath, prop->name, m->offset); 917 - append_to_property(fn, m->ref, entry, strlen(entry) + 1); 913 + append_to_property(fn, m->ref, entry, strlen(entry) + 1, TYPE_STRING); 918 914 919 915 free(entry); 920 916 } ··· 974 970 char **compp; 975 971 int i, depth; 976 972 977 - /* walk back retreiving depth */ 973 + /* walk back retrieving depth */ 978 974 depth = 0; 979 975 for (wn = node; wn; wn = wn->parent) 980 976 depth++; ··· 997 993 free(compp); 998 994 999 995 value_32 = cpu_to_fdt32(m->offset); 1000 - append_to_property(wn, prop->name, &value_32, sizeof(value_32)); 996 + append_to_property(wn, prop->name, &value_32, sizeof(value_32), TYPE_UINT32); 1001 997 } 1002 998 1003 999 static void generate_local_fixups_tree_internal(struct dt_info *dti,
+2 -2
scripts/dtc/util.h
··· 122 122 * stderr. 123 123 * 124 124 * @param filename The filename to write, or - for stdout 125 - * @param blob Poiner to buffer containing fdt 125 + * @param blob Pointer to buffer containing fdt 126 126 * @return 0 if ok, -1 on error 127 127 */ 128 128 int utilfdt_write(const char *filename, const void *blob); ··· 133 133 * an error message for the user. 134 134 * 135 135 * @param filename The filename to write, or - for stdout 136 - * @param blob Poiner to buffer containing fdt 136 + * @param blob Pointer to buffer containing fdt 137 137 * @return 0 if ok, else an errno value representing the error 138 138 */ 139 139 int utilfdt_write_err(const char *filename, const void *blob);
+1 -1
scripts/dtc/version_gen.h
··· 1 - #define DTC_VERSION "DTC 1.4.7-gf267e674" 1 + #define DTC_VERSION "DTC 1.5.0-g87963ee2"