History

scripts/dtc: Update to upstream version v1.4.6-9-gaadd0b65c987

This adds the following commits from upstream: aadd0b65c987 checks: centralize printing of property names in failure messages 88960e398907 checks: centralize printing of node path in check_msg f1879e1a50eb Add limited read-only support for older (V2 and V3) device tree to libfdt. 37dea76e9700 srcpos: drop special handling of tab 65893da4aee0 libfdt: overlay: Add missing license 962a45ca034d Avoid installing pylibfdt when dependencies are missing cd6ea1b2bea6 Makefile: Split INSTALL out into INSTALL_{PROGRAM,LIB,DATA,SCRIPT} 51b3a16338df Makefile.tests: Add LIBDL make(1) variable for portability sake 333d533a8f4d Attempt to auto-detect stat(1) being used if not given proper invocation e54388015af1 dtc: Bump version to v1.4.6 a1fe86f380cb fdtoverlay: Switch from using alloca to malloc c8d5472de3ff tests: Improve compatibility with other platforms c81d389a10cc checks: add chosen node checks e671852042a7 checks: add aliases node checks d0c44ebe3f42 checks: check for #{size,address}-cells without child nodes 18a3d84bb802 checks: add string list check for *-names properties 8fe94fd6f19f checks: add string list check 6c5730819604 checks: add a string check for 'label' property a384191eba09 checks: fix sound-dai phandle with arg property check b260c4f610c0 Fix ambiguous grammar for devicetree rule fe667e382bac tests: Add some basic tests for the pci_bridge checks 7975f6422260 Fix widespread incorrect use of strneq(), replace with new strprefixeq() fca296445eab Add strstarts() helper function cc392f089007 tests: Check non-matching cases for fdt_node_check_compatible() bba26a5291c8 livetree: avoid assertion of orphan phandles with overlays c8f8194d76cc implement strnlen for systems that need it c8b38f65fdec libfdt: Remove leading underscores from identifiers 3b62fdaebfe5 Remove leading underscores from identifiers 2d45d1c5c65e Replace FDT_VERSION() with stringify() 2e6fe5a107b5 Fix some errors in comments b0ae9e4b0ceb tests: Correct warning in sw_tree1.c Commit c8b38f65fdec upstream ("libfdt: Remove leading underscores from identifiers") changed the multiple inclusion define protection, so the kernel's libfdt_env.h needs the corresponding update.

Rob Herring committed 8 years ago

Commit 9130ba81 parent e03913921 files · +622 −320Browse files

Unified · Split

21 files
  1. include/linux/libfdt_env.h +3 −3
  2. scripts/dtc/checks.c +290 −149
  3. scripts/dtc/dtc-parser.y +11 −6
  4. scripts/dtc/dtc.c +3 −4
  5. scripts/dtc/dtc.h +6 −5
  6. scripts/dtc/flattree.c +1 −1
  7. scripts/dtc/libfdt/fdt.c +8 −5
  8. scripts/dtc/libfdt/fdt.h +3 −3
  9. scripts/dtc/libfdt/fdt_overlay.c +51 −0
  10. scripts/dtc/libfdt/fdt_ro.c +101 −31
  11. scripts/dtc/libfdt/fdt_rw.c +45 −45
  12. scripts/dtc/libfdt/fdt_sw.c +12 −12
  13. scripts/dtc/libfdt/fdt_wip.c +5 −5
  14. scripts/dtc/libfdt/libfdt.h +20 −17
  15. scripts/dtc/libfdt/libfdt_env.h +30 −3
  16. scripts/dtc/libfdt/libfdt_internal.h +16 −16
  17. scripts/dtc/livetree.c +7 −3
  18. scripts/dtc/srcpos.c +0 −5
  19. scripts/dtc/srcpos.h +3 −3
  20. scripts/dtc/util.h +6 −3
  21. scripts/dtc/version_gen.h +1 −1
include/linux/libfdt_env.h+3−3
@@ -1,6 +1,6 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _LIBFDT_ENV_H
3−#define _LIBFDT_ENV_H
2+#ifndef LIBFDT_ENV_H
3+#define LIBFDT_ENV_H
44
55 #include <linux/string.h>
66
@@ -15,4 +15,4 @@ typedef __be64 fdt64_t; · 8 unmodified lines
1515 #define fdt64_to_cpu(x) be64_to_cpu(x)
1616 #define cpu_to_fdt64(x) cpu_to_be64(x)
1717
18−#endif /* _LIBFDT_ENV_H */
18+#endif /* LIBFDT_ENV_H */
scripts/dtc/checks.c+290−149
@@ -53,26 +53,28 @@ struct check { · 52 unmodified lines
5353 struct check **prereq;
5454 };
5555
56−#define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \
57− static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \
58− static struct check _nm = { \
59− .name = #_nm, \
60− .fn = (_fn), \
61− .data = (_d), \
62− .warn = (_w), \
63− .error = (_e), \
56+#define CHECK_ENTRY(nm_, fn_, d_, w_, e_, ...) \
57+ static struct check *nm_##_prereqs[] = { __VA_ARGS__ }; \
58+ static struct check nm_ = { \
59+ .name = #nm_, \
60+ .fn = (fn_), \
61+ .data = (d_), \
62+ .warn = (w_), \
63+ .error = (e_), \
6464 .status = UNCHECKED, \
65− .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \
66− .prereq = _nm##_prereqs, \
65+ .num_prereqs = ARRAY_SIZE(nm_##_prereqs), \
66+ .prereq = nm_##_prereqs, \
6767 };
68−#define WARNING(_nm, _fn, _d, ...) \
69− CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__)
70−#define ERROR(_nm, _fn, _d, ...) \
71− CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__)
72−#define CHECK(_nm, _fn, _d, ...) \
73− CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
74−
75−static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,
68+#define WARNING(nm_, fn_, d_, ...) \
69+ CHECK_ENTRY(nm_, fn_, d_, true, false, __VA_ARGS__)
70+#define ERROR(nm_, fn_, d_, ...) \
71+ CHECK_ENTRY(nm_, fn_, d_, false, true, __VA_ARGS__)
72+#define CHECK(nm_, fn_, d_, ...) \
73+ CHECK_ENTRY(nm_, fn_, d_, false, false, __VA_ARGS__)
74+
75+static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
76+ struct node *node,
77+ struct property *prop,
7678 const char *fmt, ...)
7779 {
7880 va_list ap;
@@ -83,19 +85,33 @@ static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, · 4 unmodified lines
8385 fprintf(stderr, "%s: %s (%s): ",
8486 strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
8587 (c->error) ? "ERROR" : "Warning", c->name);
88+ if (node) {
89+ fprintf(stderr, "%s", node->fullpath);
90+ if (prop)
91+ fprintf(stderr, ":%s", prop->name);
92+ fputs(": ", stderr);
93+ }
8694 vfprintf(stderr, fmt, ap);
8795 fprintf(stderr, "\n");
8896 }
8997 va_end(ap);
9098 }
9199
92−#define FAIL(c, dti, ...) \
100+#define FAIL(c, dti, node, ...) \
101+ do { \
102+ TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
103+ (c)->status = FAILED; \
104+ check_msg((c), dti, node, NULL, __VA_ARGS__); \
105+ } while (0)
106+
107+#define FAIL_PROP(c, dti, node, prop, ...) \
93108 do { \
94109 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
95110 (c)->status = FAILED; \
96− check_msg((c), dti, __VA_ARGS__); \
111+ check_msg((c), dti, node, prop, __VA_ARGS__); \
97112 } while (0)
98113
114+
99115 static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
100116 {
101117 struct node *child;
@@ -126,7 +142,7 @@ static bool run_check(struct check *c, struct dt_info *dti) · 24 unmodified lines
126142 error = error || run_check(prq, dti);
127143 if (prq->status != PASSED) {
128144 c->status = PREREQ;
129− check_msg(c, dti, "Failed prerequisite '%s'",
145+ check_msg(c, dti, NULL, NULL, "Failed prerequisite '%s'",
130146 c->prereq[i]->name);
131147 }
132148 }
@@ -156,7 +172,7 @@ out: · 23 unmodified lines
156172 static inline void check_always_fail(struct check *c, struct dt_info *dti,
157173 struct node *node)
158174 {
159− FAIL(c, dti, "always_fail check");
175+ FAIL(c, dti, node, "always_fail check");
160176 }
161177 CHECK(always_fail, check_always_fail, NULL);
162178
@@ -171,14 +187,42 @@ static void check_is_string(struct check *c, struct dt_info *dti, · 8 unmodified lines
171187 return; /* Not present, assumed ok */
172188
173189 if (!data_is_one_string(prop->val))
174− FAIL(c, dti, "\"%s\" property in %s is not a string",
175− propname, node->fullpath);
190+ FAIL_PROP(c, dti, node, prop, "property is not a string");
176191 }
177192 #define WARNING_IF_NOT_STRING(nm, propname) \
178193 WARNING(nm, check_is_string, (propname))
179194 #define ERROR_IF_NOT_STRING(nm, propname) \
180195 ERROR(nm, check_is_string, (propname))
181196
197+static void check_is_string_list(struct check *c, struct dt_info *dti,
198+ struct node *node)
199+{
200+ int rem, l;
201+ struct property *prop;
202+ char *propname = c->data;
203+ char *str;
204+
205+ prop = get_property(node, propname);
206+ if (!prop)
207+ return; /* Not present, assumed ok */
208+
209+ str = prop->val.val;
210+ rem = prop->val.len;
211+ while (rem > 0) {
212+ l = strnlen(str, rem);
213+ if (l == rem) {
214+ FAIL_PROP(c, dti, node, prop, "property is not a string list");
215+ break;
216+ }
217+ rem -= l + 1;
218+ str += l + 1;
219+ }
220+}
221+#define WARNING_IF_NOT_STRING_LIST(nm, propname) \
222+ WARNING(nm, check_is_string_list, (propname))
223+#define ERROR_IF_NOT_STRING_LIST(nm, propname) \
224+ ERROR(nm, check_is_string_list, (propname))
225+
182226 static void check_is_cell(struct check *c, struct dt_info *dti,
183227 struct node *node)
184228 {
@@ -190,8 +234,7 @@ static void check_is_cell(struct check *c, struct dt_info *dti, · 5 unmodified lines
190234 return; /* Not present, assumed ok */
191235
192236 if (prop->val.len != sizeof(cell_t))
193− FAIL(c, dti, "\"%s\" property in %s is not a single cell",
194− propname, node->fullpath);
237+ FAIL_PROP(c, dti, node, prop, "property is not a single cell");
195238 }
196239 #define WARNING_IF_NOT_CELL(nm, propname) \
197240 WARNING(nm, check_is_cell, (propname))
@@ -212,8 +255,7 @@ static void check_duplicate_node_names(struct check *c, struct dt_info *dti, · 14 unmodified lines
212255 child2;
213256 child2 = child2->next_sibling)
214257 if (streq(child->name, child2->name))
215− FAIL(c, dti, "Duplicate node name %s",
216− child->fullpath);
258+ FAIL(c, dti, node, "Duplicate node name");
217259 }
218260 ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
219261
@@ -227,8 +269,7 @@ static void check_duplicate_property_names(struct check *c, struct dt_info *dti, · 7 unmodified lines
227269 if (prop2->deleted)
228270 continue;
229271 if (streq(prop->name, prop2->name))
230− FAIL(c, dti, "Duplicate property name %s in %s",
231− prop->name, node->fullpath);
272+ FAIL_PROP(c, dti, node, prop, "Duplicate property name");
232273 }
233274 }
234275 }
@@ -246,8 +287,8 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti, · 11 unmodified lines
246287 int n = strspn(node->name, c->data);
247288
248289 if (n < strlen(node->name))
249− FAIL(c, dti, "Bad character '%c' in node %s",
250− node->name[n], node->fullpath);
290+ FAIL(c, dti, node, "Bad character '%c' in node name",
291+ node->name[n]);
251292 }
252293 ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
253294
@@ -257,8 +298,8 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, · 3 unmodified lines
257298 int n = strspn(node->name, c->data);
258299
259300 if (n < node->basenamelen)
260− FAIL(c, dti, "Character '%c' not recommended in node %s",
261− node->name[n], node->fullpath);
301+ FAIL(c, dti, node, "Character '%c' not recommended in node name",
302+ node->name[n]);
262303 }
263304 CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT);
264305
@@ -266,8 +307,7 @@ static void check_node_name_format(struct check *c, struct dt_info *dti, · 1 unmodified line
266307 struct node *node)
267308 {
268309 if (strchr(get_unitname(node), '@'))
269− FAIL(c, dti, "Node %s has multiple '@' characters in name",
270− node->fullpath);
310+ FAIL(c, dti, node, "multiple '@' characters in node name");
271311 }
272312 ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
273313
@@ -285,12 +325,10 @@ static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, · 11 unmodified lines
285325
286326 if (prop) {
287327 if (!unitname[0])
288− FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name",
289− node->fullpath);
328+ FAIL(c, dti, node, "node has a reg or ranges property, but no unit name");
290329 } else {
291330 if (unitname[0])
292− FAIL(c, dti, "Node %s has a unit name, but no reg property",
293− node->fullpath);
331+ FAIL(c, dti, node, "node has a unit name, but no reg property");
294332 }
295333 }
296334 WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL);
@@ -304,8 +342,8 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti, · 7 unmodified lines
304342 int n = strspn(prop->name, c->data);
305343
306344 if (n < strlen(prop->name))
307− FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s",
308− prop->name[n], prop->name, node->fullpath);
345+ FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name",
346+ prop->name[n]);
309347 }
310348 }
311349 ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
@@ -336,8 +374,8 @@ static void check_property_name_chars_strict(struct check *c, · 24 unmodified lines
336374 n = strspn(name, c->data);
337375 }
338376 if (n < strlen(name))
339− FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s",
340− name[n], prop->name, node->fullpath);
377+ FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name",
378+ name[n]);
341379 }
342380 }
343381 CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT);
@@ -370,7 +408,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti, · 26 unmodified lines
370408 return;
371409
372410 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
373− FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT
411+ FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT
374412 " and " DESCLABEL_FMT,
375413 label, DESCLABEL_ARGS(node, prop, mark),
376414 DESCLABEL_ARGS(othernode, otherprop, othermark));
@@ -410,8 +448,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 33 unmodified lines
410448 return 0;
411449
412450 if (prop->val.len != sizeof(cell_t)) {
413− FAIL(c, dti, "%s has bad length (%d) %s property",
414− node->fullpath, prop->val.len, prop->name);
451+ FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property",
452+ prop->val.len, prop->name);
415453 return 0;
416454 }
417455
@@ -422,8 +460,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 4 unmodified lines
422460 /* "Set this node's phandle equal to some
423461 * other node's phandle". That's nonsensical
424462 * by construction. */ {
425− FAIL(c, dti, "%s in %s is a reference to another node",
426− prop->name, node->fullpath);
463+ FAIL(c, dti, node, "%s is a reference to another node",
464+ prop->name);
427465 }
428466 /* But setting this node's phandle equal to its own
429467 * phandle is allowed - that means allocate a unique
@@ -436,8 +474,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 6 unmodified lines
436474 phandle = propval_cell(prop);
437475
438476 if ((phandle == 0) || (phandle == -1)) {
439− FAIL(c, dti, "%s has bad value (0x%x) in %s property",
440− node->fullpath, phandle, prop->name);
477+ FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property",
478+ phandle, prop->name);
441479 return 0;
442480 }
443481
@@ -463,16 +501,16 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti, · 19 unmodified lines
463501 return;
464502
465503 if (linux_phandle && phandle && (phandle != linux_phandle))
466− FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'"
467− " properties", node->fullpath);
504+ FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'"
505+ " properties");
468506
469507 if (linux_phandle && !phandle)
470508 phandle = linux_phandle;
471509
472510 other = get_node_by_phandle(root, phandle);
473511 if (other && (other != node)) {
474− FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)",
475− node->fullpath, phandle, other->fullpath);
512+ FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)",
513+ phandle, other->fullpath);
476514 return;
477515 }
478516
@@ -496,8 +534,8 @@ static void check_name_properties(struct check *c, struct dt_info *dti, · 17 unmodified lines
496534
497535 if ((prop->val.len != node->basenamelen+1)
498536 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
499− FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead"
500− " of base node name)", node->fullpath, prop->val.val);
537+ FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead"
538+ " of base node name)", prop->val.val);
501539 } else {
502540 /* The name property is correct, and therefore redundant.
503541 * Delete it */
@@ -531,7 +569,7 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti, · 27 unmodified lines
531569 refnode = get_node_by_ref(dt, m->ref);
532570 if (! refnode) {
533571 if (!(dti->dtsflags & DTSF_PLUGIN))
534− FAIL(c, dti, "Reference to non-existent node or "
572+ FAIL(c, dti, node, "Reference to non-existent node or "
535573 "label \"%s\"\n", m->ref);
536574 else /* mark the entry as unresolved */
537575 *((fdt32_t *)(prop->val.val + m->offset)) =
@@ -563,7 +601,7 @@ static void fixup_path_references(struct check *c, struct dt_info *dti, · 25 unmodified lines
563601
564602 refnode = get_node_by_ref(dt, m->ref);
565603 if (!refnode) {
566− FAIL(c, dti, "Reference to non-existent node or label \"%s\"\n",
604+ FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n",
567605 m->ref);
568606 continue;
569607 }
@@ -586,6 +624,45 @@ WARNING_IF_NOT_CELL(interrupt_cells_is_cell, "#interrupt-cells"); · 16 unmodified lines
586624 WARNING_IF_NOT_STRING(device_type_is_string, "device_type");
587625 WARNING_IF_NOT_STRING(model_is_string, "model");
588626 WARNING_IF_NOT_STRING(status_is_string, "status");
627+WARNING_IF_NOT_STRING(label_is_string, "label");
628+
629+WARNING_IF_NOT_STRING_LIST(compatible_is_string_list, "compatible");
630+
631+static void check_names_is_string_list(struct check *c, struct dt_info *dti,
632+ struct node *node)
633+{
634+ struct property *prop;
635+
636+ for_each_property(node, prop) {
637+ const char *s = strrchr(prop->name, '-');
638+ if (!s || !streq(s, "-names"))
639+ continue;
640+
641+ c->data = prop->name;
642+ check_is_string_list(c, dti, node);
643+ }
644+}
645+WARNING(names_is_string_list, check_names_is_string_list, NULL);
646+
647+static void check_alias_paths(struct check *c, struct dt_info *dti,
648+ struct node *node)
649+{
650+ struct property *prop;
651+
652+ if (!streq(node->name, "aliases"))
653+ return;
654+
655+ for_each_property(node, prop) {
656+ if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) {
657+ FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)",
658+ prop->val.val);
659+ continue;
660+ }
661+ if (strspn(prop->name, LOWERCASE DIGITS "-") != strlen(prop->name))
662+ FAIL(c, dti, node, "aliases property name must include only lowercase and '-'");
663+ }
664+}
665+WARNING(alias_paths, check_alias_paths, NULL);
589666
590667 static void fixup_addr_size_cells(struct check *c, struct dt_info *dti,
591668 struct node *node)
@@ -622,21 +699,21 @@ static void check_reg_format(struct check *c, struct dt_info *dti, · 30 unmodified lines
622699 return; /* No "reg", that's fine */
623700
624701 if (!node->parent) {
625− FAIL(c, dti, "Root node has a \"reg\" property");
702+ FAIL(c, dti, node, "Root node has a \"reg\" property");
626703 return;
627704 }
628705
629706 if (prop->val.len == 0)
630− FAIL(c, dti, "\"reg\" property in %s is empty", node->fullpath);
707+ FAIL_PROP(c, dti, node, prop, "property is empty");
631708
632709 addr_cells = node_addr_cells(node->parent);
633710 size_cells = node_size_cells(node->parent);
634711 entrylen = (addr_cells + size_cells) * sizeof(cell_t);
635712
636713 if (!entrylen || (prop->val.len % entrylen) != 0)
637− FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) "
638− "(#address-cells == %d, #size-cells == %d)",
639− node->fullpath, prop->val.len, addr_cells, size_cells);
714+ FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) "
715+ "(#address-cells == %d, #size-cells == %d)",
716+ prop->val.len, addr_cells, size_cells);
640717 }
641718 WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);
642719
@@ -651,7 +728,7 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 8 unmodified lines
651728 return;
652729
653730 if (!node->parent) {
654− FAIL(c, dti, "Root node has a \"ranges\" property");
731+ FAIL_PROP(c, dti, node, prop, "Root node has a \"ranges\" property");
655732 return;
656733 }
657734
@@ -663,20 +740,20 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 5 unmodified lines
663740
664741 if (prop->val.len == 0) {
665742 if (p_addr_cells != c_addr_cells)
666− FAIL(c, dti, "%s has empty \"ranges\" property but its "
667− "#address-cells (%d) differs from %s (%d)",
668− node->fullpath, c_addr_cells, node->parent->fullpath,
669− p_addr_cells);
743+ FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
744+ "#address-cells (%d) differs from %s (%d)",
745+ c_addr_cells, node->parent->fullpath,
746+ p_addr_cells);
670747 if (p_size_cells != c_size_cells)
671− FAIL(c, dti, "%s has empty \"ranges\" property but its "
672− "#size-cells (%d) differs from %s (%d)",
673− node->fullpath, c_size_cells, node->parent->fullpath,
674− p_size_cells);
748+ FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
749+ "#size-cells (%d) differs from %s (%d)",
750+ c_size_cells, node->parent->fullpath,
751+ p_size_cells);
675752 } else if ((prop->val.len % entrylen) != 0) {
676− FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) "
677− "(parent #address-cells == %d, child #address-cells == %d, "
678− "#size-cells == %d)", node->fullpath, prop->val.len,
679− p_addr_cells, c_addr_cells, c_size_cells);
753+ FAIL_PROP(c, dti, node, prop, "\"ranges\" property has invalid length (%d bytes) "
754+ "(parent #address-cells == %d, child #address-cells == %d, "
755+ "#size-cells == %d)", prop->val.len,
756+ p_addr_cells, c_addr_cells, c_size_cells);
680757 }
681758 }
682759 WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
@@ -696,41 +773,33 @@ static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node * · 13 unmodified lines
696773
697774 node->bus = &pci_bus;
698775
699− if (!strneq(node->name, "pci", node->basenamelen) &&
700− !strneq(node->name, "pcie", node->basenamelen))
701− FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"",
702− node->fullpath);
776+ if (!strprefixeq(node->name, node->basenamelen, "pci") &&
777+ !strprefixeq(node->name, node->basenamelen, "pcie"))
778+ FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\"");
703779
704780 prop = get_property(node, "ranges");
705781 if (!prop)
706− FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)",
707− node->fullpath);
782+ FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)");
708783
709784 if (node_addr_cells(node) != 3)
710− FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge",
711− node->fullpath);
785+ FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
712786 if (node_size_cells(node) != 2)
713− FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge",
714− node->fullpath);
787+ FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
715788
716789 prop = get_property(node, "bus-range");
717790 if (!prop) {
718− FAIL(c, dti, "Node %s missing bus-range for PCI bridge",
719− node->fullpath);
791+ FAIL(c, dti, node, "missing bus-range for PCI bridge");
720792 return;
721793 }
722794 if (prop->val.len != (sizeof(cell_t) * 2)) {
723− FAIL(c, dti, "Node %s bus-range must be 2 cells",
724− node->fullpath);
795+ FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
725796 return;
726797 }
727798 cells = (cell_t *)prop->val.val;
728799 if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1]))
729− FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell",
730− node->fullpath);
800+ FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
731801 if (fdt32_to_cpu(cells[1]) > 0xff)
732− FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256",
733− node->fullpath);
802+ FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256");
734803 }
735804 WARNING(pci_bridge, check_pci_bridge, NULL,
736805 &device_type_is_string, &addr_size_cells);
@@ -760,8 +829,8 @@ static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struc · 23 unmodified lines
760829 max_bus = fdt32_to_cpu(cells[0]);
761830 }
762831 if ((bus_num < min_bus) || (bus_num > max_bus))
763− FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)",
764− node->fullpath, bus_num, min_bus, max_bus);
832+ FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
833+ bus_num, min_bus, max_bus);
765834 }
766835 WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, &reg_format, &pci_bridge);
767836
@@ -778,25 +847,22 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no · 10 unmodified lines
778847
779848 prop = get_property(node, "reg");
780849 if (!prop) {
781− FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath);
850+ FAIL(c, dti, node, "missing PCI reg property");
782851 return;
783852 }
784853
785854 cells = (cell_t *)prop->val.val;
786855 if (cells[1] || cells[2])
787− FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0",
788− node->fullpath);
856+ FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
789857
790858 reg = fdt32_to_cpu(cells[0]);
791859 dev = (reg & 0xf800) >> 11;
792860 func = (reg & 0x700) >> 8;
793861
794862 if (reg & 0xff000000)
795− FAIL(c, dti, "Node %s PCI reg address is not configuration space",
796− node->fullpath);
863+ FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space");
797864 if (reg & 0x000000ff)
798− FAIL(c, dti, "Node %s PCI reg config space address register number must be 0",
799− node->fullpath);
865+ FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0");
800866
801867 if (func == 0) {
802868 snprintf(unit_addr, sizeof(unit_addr), "%x", dev);
@@ -808,8 +874,8 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no · 5 unmodified lines
808874 if (streq(unitname, unit_addr))
809875 return;
810876
811− FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"",
812− node->fullpath, unit_addr);
877+ FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"",
878+ unit_addr);
813879 }
814880 WARNING(pci_device_reg, check_pci_device_reg, NULL, &reg_format, &pci_bridge);
815881
@@ -828,7 +894,7 @@ static bool node_is_compatible(struct node *node, const char *compat) · 12 unmodified lines
828894
829895 for (str = prop->val.val, end = str + prop->val.len; str < end;
830896 str += strnlen(str, end - str) + 1) {
831− if (strneq(str, compat, end - str))
897+ if (strprefixeq(str, end - str, compat))
832898 return true;
833899 }
834900 return false;
@@ -865,7 +931,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no · 30 unmodified lines
865931
866932 if (!cells) {
867933 if (node->parent->parent && !(node->bus == &simple_bus))
868− FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath);
934+ FAIL(c, dti, node, "missing or empty reg/ranges property");
869935 return;
870936 }
871937
@@ -875,8 +941,8 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no · 3 unmodified lines
875941
876942 snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);
877943 if (!streq(unitname, unit_addr))
878− FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
879− node->fullpath, unit_addr);
944+ FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
945+ unit_addr);
880946 }
881947 WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge);
882948
@@ -892,14 +958,12 @@ static void check_unit_address_format(struct check *c, struct dt_info *dti, · 9 unmodified lines
892958 return;
893959
894960 if (!strncmp(unitname, "0x", 2)) {
895− FAIL(c, dti, "Node %s unit name should not have leading \"0x\"",
896− node->fullpath);
961+ FAIL(c, dti, node, "unit name should not have leading \"0x\"");
897962 /* skip over 0x for next test */
898963 unitname += 2;
899964 }
900965 if (unitname[0] == '0' && isxdigit(unitname[1]))
901− FAIL(c, dti, "Node %s unit name should not have leading 0s",
902− node->fullpath);
966+ FAIL(c, dti, node, "unit name should not have leading 0s");
903967 }
904968 WARNING(unit_address_format, check_unit_address_format, NULL,
905969 &node_name_format, &pci_bridge, &simple_bus_bridge);
@@ -922,16 +986,38 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti, · 16 unmodified lines
922986 return;
923987
924988 if (node->parent->addr_cells == -1)
925− FAIL(c, dti, "Relying on default #address-cells value for %s",
926− node->fullpath);
989+ FAIL(c, dti, node, "Relying on default #address-cells value");
927990
928991 if (node->parent->size_cells == -1)
929− FAIL(c, dti, "Relying on default #size-cells value for %s",
930− node->fullpath);
992+ FAIL(c, dti, node, "Relying on default #size-cells value");
931993 }
932994 WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
933995 &addr_size_cells);
934996
997+static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *dti,
998+ struct node *node)
999+{
1000+ struct property *prop;
1001+ struct node *child;
1002+ bool has_reg = false;
1003+
1004+ if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
1005+ return;
1006+
1007+ if (get_property(node, "ranges") || !node->children)
1008+ return;
1009+
1010+ for_each_child(node, child) {
1011+ prop = get_property(child, "reg");
1012+ if (prop)
1013+ has_reg = true;
1014+ }
1015+
1016+ if (!has_reg)
1017+ FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" property");
1018+}
1019+WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
1020+
9351021 static void check_obsolete_chosen_interrupt_controller(struct check *c,
9361022 struct dt_info *dti,
9371023 struct node *node)
@@ -950,12 +1036,61 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, · 12 unmodified lines
9501036
9511037 prop = get_property(chosen, "interrupt-controller");
9521038 if (prop)
953− FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" "
954− "property");
1039+ FAIL_PROP(c, dti, node, prop,
1040+ "/chosen has obsolete \"interrupt-controller\" property");
9551041 }
9561042 WARNING(obsolete_chosen_interrupt_controller,
9571043 check_obsolete_chosen_interrupt_controller, NULL);
9581044
1045+static void check_chosen_node_is_root(struct check *c, struct dt_info *dti,
1046+ struct node *node)
1047+{
1048+ if (!streq(node->name, "chosen"))
1049+ return;
1050+
1051+ if (node->parent != dti->dt)
1052+ FAIL(c, dti, node, "chosen node must be at root node");
1053+}
1054+WARNING(chosen_node_is_root, check_chosen_node_is_root, NULL);
1055+
1056+static void check_chosen_node_bootargs(struct check *c, struct dt_info *dti,
1057+ struct node *node)
1058+{
1059+ struct property *prop;
1060+
1061+ if (!streq(node->name, "chosen"))
1062+ return;
1063+
1064+ prop = get_property(node, "bootargs");
1065+ if (!prop)
1066+ return;
1067+
1068+ c->data = prop->name;
1069+ check_is_string(c, dti, node);
1070+}
1071+WARNING(chosen_node_bootargs, check_chosen_node_bootargs, NULL);
1072+
1073+static void check_chosen_node_stdout_path(struct check *c, struct dt_info *dti,
1074+ struct node *node)
1075+{
1076+ struct property *prop;
1077+
1078+ if (!streq(node->name, "chosen"))
1079+ return;
1080+
1081+ prop = get_property(node, "stdout-path");
1082+ if (!prop) {
1083+ prop = get_property(node, "linux,stdout-path");
1084+ if (!prop)
1085+ return;
1086+ FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead");
1087+ }
1088+
1089+ c->data = prop->name;
1090+ check_is_string(c, dti, node);
1091+}
1092+WARNING(chosen_node_stdout_path, check_chosen_node_stdout_path, NULL);
1093+
9591094 struct provider {
9601095 const char *prop_name;
9611096 const char *cell_name;
@@ -972,8 +1107,9 @@ static void check_property_phandle_args(struct check *c, · 10 unmodified lines
9721107 int cell, cellsize = 0;
9731108
9741109 if (prop->val.len % sizeof(cell_t)) {
975− FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
976− prop->name, prop->val.len, sizeof(cell_t), node->fullpath);
1110+ FAIL_PROP(c, dti, node, prop,
1111+ "property size (%d) is invalid, expected multiple of %zu",
1112+ prop->val.len, sizeof(cell_t));
9771113 return;
9781114 }
9791115
@@ -1004,14 +1140,16 @@ static void check_property_phandle_args(struct check *c, · 24 unmodified lines
10041140 break;
10051141 }
10061142 if (!m)
1007− FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s",
1008− prop->name, cell, node->fullpath);
1143+ FAIL_PROP(c, dti, node, prop,
1144+ "cell %d is not a phandle reference",
1145+ cell);
10091146 }
10101147
10111148 provider_node = get_node_by_phandle(root, phandle);
10121149 if (!provider_node) {
1013− FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)",
1014− node->fullpath, prop->name, cell);
1150+ FAIL_PROP(c, dti, node, prop,
1151+ "Could not get phandle node for (cell %d)",
1152+ cell);
10151153 break;
10161154 }
10171155
@@ -1021,16 +1159,17 @@ static void check_property_phandle_args(struct check *c, · 3 unmodified lines
10211159 } else if (provider->optional) {
10221160 cellsize = 0;
10231161 } else {
1024− FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])",
1162+ FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])",
10251163 provider->cell_name,
10261164 provider_node->fullpath,
1027− node->fullpath, prop->name, cell);
1165+ prop->name, cell);
10281166 break;
10291167 }
10301168
10311169 if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) {
1032− FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s",
1033− prop->name, prop->val.len, cellsize, node->fullpath);
1170+ FAIL_PROP(c, dti, node, prop,
1171+ "property size (%d) too small for cell size %d",
1172+ prop->val.len, cellsize);
10341173 }
10351174 }
10361175 }
@@ -1066,7 +1205,7 @@ WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells"); · 29 unmodified lines
10661205 WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
10671206 WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
10681207 WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
1069−WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells");
1208+WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells");
10701209 WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
10711210
10721211 static bool prop_is_gpio(struct property *prop)
@@ -1132,8 +1271,8 @@ static void check_deprecated_gpio_property(struct check *c, · 59 unmodified lines
11321271 if (!streq(str, "gpio"))
11331272 continue;
11341273
1135− FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s",
1136− node->fullpath, prop->name);
1274+ FAIL_PROP(c, dti, node, prop,
1275+ "'[*-]gpio' is deprecated, use '[*-]gpios' instead");
11371276 }
11381277
11391278 }
@@ -1167,9 +1306,8 @@ static void check_interrupts_property(struct check *c, · 27 unmodified lines
11671306 return;
11681307
11691308 if (irq_prop->val.len % sizeof(cell_t))
1170− FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
1171− irq_prop->name, irq_prop->val.len, sizeof(cell_t),
1172− node->fullpath);
1309+ FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu",
1310+ irq_prop->val.len, sizeof(cell_t));
11731311
11741312 while (parent && !prop) {
11751313 if (parent != node && node_is_interrupt_provider(parent)) {
@@ -1187,14 +1325,12 @@ static void check_interrupts_property(struct check *c, · 11 unmodified lines
11871325
11881326 irq_node = get_node_by_phandle(root, phandle);
11891327 if (!irq_node) {
1190− FAIL(c, dti, "Bad interrupt-parent phandle for %s",
1191− node->fullpath);
1328+ FAIL_PROP(c, dti, parent, prop, "Bad phandle");
11921329 return;
11931330 }
11941331 if (!node_is_interrupt_provider(irq_node))
1195− FAIL(c, dti,
1196− "Missing interrupt-controller or interrupt-map property in %s",
1197− irq_node->fullpath);
1332+ FAIL(c, dti, irq_node,
1333+ "Missing interrupt-controller or interrupt-map property");
11981334
11991335 break;
12001336 }
@@ -1203,23 +1339,21 @@ static void check_interrupts_property(struct check *c, · 2 unmodified lines
12031339 }
12041340
12051341 if (!irq_node) {
1206− FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath);
1342+ FAIL(c, dti, node, "Missing interrupt-parent");
12071343 return;
12081344 }
12091345
12101346 prop = get_property(irq_node, "#interrupt-cells");
12111347 if (!prop) {
1212− FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s",
1213− irq_node->fullpath);
1348+ FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent");
12141349 return;
12151350 }
12161351
12171352 irq_cells = propval_cell(prop);
12181353 if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
1219− FAIL(c, dti,
1220− "interrupts size is (%d), expected multiple of %d in %s",
1221− irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)),
1222− node->fullpath);
1354+ FAIL_PROP(c, dti, node, prop,
1355+ "size is (%d), expected multiple of %d",
1356+ irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)));
12231357 }
12241358 }
12251359 WARNING(interrupts_property, check_interrupts_property, &phandle_references);
@@ -1236,6 +1370,9 @@ static struct check *check_table[] = { · 10 unmodified lines
12361370
12371371 &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
12381372 &device_type_is_string, &model_is_string, &status_is_string,
1373+ &label_is_string,
1374+
1375+ &compatible_is_string_list, &names_is_string_list,
12391376
12401377 &property_name_chars_strict,
12411378 &node_name_chars_strict,
@@ -1253,7 +1390,9 @@ static struct check *check_table[] = { · 11 unmodified lines
12531390 &simple_bus_reg,
12541391
12551392 &avoid_default_addr_size,
1393+ &avoid_unnecessary_addr_size,
12561394 &obsolete_chosen_interrupt_controller,
1395+ &chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path,
12571396
12581397 &clocks_property,
12591398 &cooling_device_property,
@@ -1269,13 +1408,15 @@ static struct check *check_table[] = { · 9 unmodified lines
12691408 &power_domains_property,
12701409 &pwms_property,
12711410 &resets_property,
1272− &sound_dais_property,
1411+ &sound_dai_property,
12731412 &thermal_sensors_property,
12741413
12751414 &deprecated_gpio_property,
12761415 &gpios_property,
12771416 &interrupts_property,
12781417
1418+ &alias_paths,
1419+
12791420 &always_fail,
12801421 };
12811422
scripts/dtc/dtc-parser.y+11−6
@@ -166,7 +166,17 @@ devicetree: · 165 unmodified lines
166166 {
167167 $$ = merge_nodes($1, $3);
168168 }
169−
169+ | DT_REF nodedef
170+ {
171+ /*
172+ * We rely on the rule being always:
173+ * versioninfo plugindecl memreserves devicetree
174+ * so $-1 is what we want (plugindecl)
175+ */
176+ if (!($<flags>-1 & DTSF_PLUGIN))
177+ ERROR(&@2, "Label or path %s not found", $1);
178+ $$ = add_orphan_node(name_node(build_node(NULL, NULL), ""), $2, $1);
179+ }
170180 | devicetree DT_LABEL DT_REF nodedef
171181 {
172182 struct node *target = get_node_by_ref($1, $3);
@@ -209,11 +219,6 @@ devicetree: · 36 unmodified lines
209219
210220 $$ = $1;
211221 }
212− | /* empty */
213− {
214− /* build empty node */
215− $$ = name_node(build_node(NULL, NULL), "");
216− }
217222 ;
218223
219224 nodedef:
scripts/dtc/dtc.c+3−4
@@ -59,8 +59,6 @@ static void fill_fullpaths(struct node *tree, const char *prefix) · 58 unmodified lines
5959 }
6060
6161 /* Usage related data. */
62−#define FDT_VERSION(version) _FDT_VERSION(version)
63−#define _FDT_VERSION(version) #version
6462 static const char usage_synopsis[] = "dtc [options] <input file>";
6563 static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
6664 static struct option const usage_long_opts[] = {
@@ -98,7 +96,7 @@ static const char * const usage_opts_help[] = { · 31 unmodified lines
9896 "\t\tdts - device tree source text\n"
9997 "\t\tdtb - device tree blob\n"
10098 "\t\tasm - assembler source",
101− "\n\tBlob version to produce, defaults to "FDT_VERSION(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
99+ "\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
102100 "\n\tOutput dependency file",
103101 "\n\tMake space for <number> reserve map entries (for dtb and asm output)",
104102 "\n\tMake the blob at least <bytes> long (extra space)",
@@ -319,13 +317,14 @@ int main(int argc, char *argv[]) · 214 unmodified lines
319317 dti->boot_cpuid_phys = cmdline_boot_cpuid;
320318
321319 fill_fullpaths(dti->dt, "");
322− process_checks(force, dti);
323320
324321 /* on a plugin, generate by default */
325322 if (dti->dtsflags & DTSF_PLUGIN) {
326323 generate_fixups = 1;
327324 }
328325
326+ process_checks(force, dti);
327+
329328 if (auto_label_aliases)
330329 generate_label_tree(dti, "aliases", false);
331330
scripts/dtc/dtc.h+6−5
@@ -1,5 +1,5 @@
1−#ifndef _DTC_H
2−#define _DTC_H
1+#ifndef DTC_H
2+#define DTC_H
33
44 /*
55 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
@@ -67,7 +67,8 @@ typedef uint32_t cell_t; · 61 unmodified lines
6767
6868
6969 #define streq(a, b) (strcmp((a), (b)) == 0)
70−#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
70+#define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0)
71+#define strprefixeq(a, n, b) (strlen(b) == (n) && (memcmp(a, b, n) == 0))
7172
7273 #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
7374
@@ -203,7 +204,7 @@ struct node *build_node_delete(void); · 129 unmodified lines
203204 struct node *name_node(struct node *node, char *name);
204205 struct node *chain_node(struct node *first, struct node *list);
205206 struct node *merge_nodes(struct node *old_node, struct node *new_node);
206−void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
207+struct node *add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
207208
208209 void add_property(struct node *node, struct property *prop);
209210 void delete_property_by_name(struct node *node, char *name);
@@ -289,4 +290,4 @@ struct dt_info *dt_from_source(const char *f); · 79 unmodified lines
289290
290291 struct dt_info *dt_from_fs(const char *dirname);
291292
292−#endif /* _DTC_H */
293+#endif /* DTC_H */
scripts/dtc/flattree.c+1−1
@@ -731,7 +731,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath) · 730 unmodified lines
731731
732732 plen = strlen(ppath);
733733
734− if (!strneq(ppath, cpath, plen))
734+ if (!strstarts(cpath, ppath))
735735 die("Path \"%s\" is not valid as a child of \"%s\"\n",
736736 cpath, ppath);
737737
scripts/dtc/libfdt/fdt.c+8−5
@@ -88,7 +88,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) · 87 unmodified lines
8888 || ((offset + len) > fdt_size_dt_struct(fdt)))
8989 return NULL;
9090
91− return _fdt_offset_ptr(fdt, offset);
91+ return fdt_offset_ptr_(fdt, offset);
9292 }
9393
9494 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
@@ -123,6 +123,9 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) · 28 unmodified lines
123123 /* skip-name offset, length and value */
124124 offset += sizeof(struct fdt_property) - FDT_TAGSIZE
125125 + fdt32_to_cpu(*lenp);
126+ if (fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >= 8 &&
127+ ((offset - fdt32_to_cpu(*lenp)) % 8) != 0)
128+ offset += 4;
126129 break;
127130
128131 case FDT_END:
@@ -141,7 +144,7 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) · 12 unmodified lines
141144 return tag;
142145 }
143146
144−int _fdt_check_node_offset(const void *fdt, int offset)
147+int fdt_check_node_offset_(const void *fdt, int offset)
145148 {
146149 if ((offset < 0) || (offset % FDT_TAGSIZE)
147150 || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
@@ -150,7 +153,7 @@ int _fdt_check_node_offset(const void *fdt, int offset) · 2 unmodified lines
150153 return offset;
151154 }
152155
153−int _fdt_check_prop_offset(const void *fdt, int offset)
156+int fdt_check_prop_offset_(const void *fdt, int offset)
154157 {
155158 if ((offset < 0) || (offset % FDT_TAGSIZE)
156159 || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))
@@ -165,7 +168,7 @@ int fdt_next_node(const void *fdt, int offset, int *depth) · 8 unmodified lines
165168 uint32_t tag;
166169
167170 if (offset >= 0)
168− if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
171+ if ((nextoffset = fdt_check_node_offset_(fdt, offset)) < 0)
169172 return nextoffset;
170173
171174 do {
@@ -227,7 +230,7 @@ int fdt_next_subnode(const void *fdt, int offset) · 55 unmodified lines
227230 return offset;
228231 }
229232
230−const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
233+const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
231234 {
232235 int len = strlen(s) + 1;
233236 const char *last = strtab + tabsize - len;
scripts/dtc/libfdt/fdt.h+3−3
@@ -1,5 +1,5 @@
1−#ifndef _FDT_H
2−#define _FDT_H
1+#ifndef FDT_H
2+#define FDT_H
33 /*
44 * libfdt - Flat Device Tree manipulation
55 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -108,4 +108,4 @@ struct fdt_property { · 102 unmodified lines
108108 #define FDT_V16_SIZE FDT_V3_SIZE
109109 #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
110110
111−#endif /* _FDT_H */
111+#endif /* FDT_H */
scripts/dtc/libfdt/fdt_overlay.c+51−0
@@ -1,3 +1,54 @@
1+/*
2+ * libfdt - Flat Device Tree manipulation
3+ * Copyright (C) 2016 Free Electrons
4+ * Copyright (C) 2016 NextThing Co.
5+ *
6+ * libfdt is dual licensed: you can use it either under the terms of
7+ * the GPL, or the BSD license, at your option.
8+ *
9+ * a) This library is free software; you can redistribute it and/or
10+ * modify it under the terms of the GNU General Public License as
11+ * published by the Free Software Foundation; either version 2 of the
12+ * License, or (at your option) any later version.
13+ *
14+ * This library is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public
20+ * License along with this library; if not, write to the Free
21+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22+ * MA 02110-1301 USA
23+ *
24+ * Alternatively,
25+ *
26+ * b) Redistribution and use in source and binary forms, with or
27+ * without modification, are permitted provided that the following
28+ * conditions are met:
29+ *
30+ * 1. Redistributions of source code must retain the above
31+ * copyright notice, this list of conditions and the following
32+ * disclaimer.
33+ * 2. Redistributions in binary form must reproduce the above
34+ * copyright notice, this list of conditions and the following
35+ * disclaimer in the documentation and/or other materials
36+ * provided with the distribution.
37+ *
38+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
39+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
40+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
43+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
49+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
50+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51+ */
152 #include "libfdt_env.h"
253
354 #include <fdt.h>
scripts/dtc/libfdt/fdt_ro.c+101−31
@@ -55,12 +55,13 @@ · 54 unmodified lines
5555
5656 #include "libfdt_internal.h"
5757
58−static int _fdt_nodename_eq(const void *fdt, int offset,
58+static int fdt_nodename_eq_(const void *fdt, int offset,
5959 const char *s, int len)
6060 {
61− const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
61+ int olen;
62+ const char *p = fdt_get_name(fdt, offset, &olen);
6263
63− if (!p)
64+ if (!p || olen < len)
6465 /* short match */
6566 return 0;
6667
@@ -80,7 +81,7 @@ const char *fdt_string(const void *fdt, int stroffset) · 13 unmodified lines
8081 return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
8182 }
8283
83−static int _fdt_string_eq(const void *fdt, int stroffset,
84+static int fdt_string_eq_(const void *fdt, int stroffset,
8485 const char *s, int len)
8586 {
8687 const char *p = fdt_string(fdt, stroffset);
@@ -117,8 +118,8 @@ uint32_t fdt_get_max_phandle(const void *fdt) · 30 unmodified lines
117118 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
118119 {
119120 FDT_CHECK_HEADER(fdt);
120− *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
121− *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
121+ *address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address);
122+ *size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size);
122123 return 0;
123124 }
124125
@@ -126,12 +127,12 @@ int fdt_num_mem_rsv(const void *fdt) · 1 unmodified line
126127 {
127128 int i = 0;
128129
129− while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)
130+ while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0)
130131 i++;
131132 return i;
132133 }
133134
134−static int _nextprop(const void *fdt, int offset)
135+static int nextprop_(const void *fdt, int offset)
135136 {
136137 uint32_t tag;
137138 int nextoffset;
@@ -166,7 +167,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset, · 28 unmodified lines
166167 (offset >= 0) && (depth >= 0);
167168 offset = fdt_next_node(fdt, offset, &depth))
168169 if ((depth == 1)
169− && _fdt_nodename_eq(fdt, offset, name, namelen))
170+ && fdt_nodename_eq_(fdt, offset, name, namelen))
170171 return offset;
171172
172173 if (depth < 0)
@@ -232,17 +233,35 @@ int fdt_path_offset(const void *fdt, const char *path) · 59 unmodified lines
232233
233234 const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
234235 {
235− const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset);
236+ const struct fdt_node_header *nh = fdt_offset_ptr_(fdt, nodeoffset);
237+ const char *nameptr;
236238 int err;
237239
238240 if (((err = fdt_check_header(fdt)) != 0)
239− || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0))
241+ || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))
240242 goto fail;
241243
244+ nameptr = nh->name;
245+
246+ if (fdt_version(fdt) < 0x10) {
247+ /*
248+ * For old FDT versions, match the naming conventions of V16:
249+ * give only the leaf name (after all /). The actual tree
250+ * contents are loosely checked.
251+ */
252+ const char *leaf;
253+ leaf = strrchr(nameptr, '/');
254+ if (leaf == NULL) {
255+ err = -FDT_ERR_BADSTRUCTURE;
256+ goto fail;
257+ }
258+ nameptr = leaf+1;
259+ }
260+
242261 if (len)
243− *len = strlen(nh->name);
262+ *len = strlen(nameptr);
244263
245− return nh->name;
264+ return nameptr;
246265
247266 fail:
248267 if (len)
@@ -254,34 +273,34 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset) · 5 unmodified lines
254273 {
255274 int offset;
256275
257− if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
276+ if ((offset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
258277 return offset;
259278
260− return _nextprop(fdt, offset);
279+ return nextprop_(fdt, offset);
261280 }
262281
263282 int fdt_next_property_offset(const void *fdt, int offset)
264283 {
265− if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0)
284+ if ((offset = fdt_check_prop_offset_(fdt, offset)) < 0)
266285 return offset;
267286
268− return _nextprop(fdt, offset);
287+ return nextprop_(fdt, offset);
269288 }
270289
271−const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
272− int offset,
273− int *lenp)
290+static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt,
291+ int offset,
292+ int *lenp)
274293 {
275294 int err;
276295 const struct fdt_property *prop;
277296
278− if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) {
297+ if ((err = fdt_check_prop_offset_(fdt, offset)) < 0) {
279298 if (lenp)
280299 *lenp = err;
281300 return NULL;
282301 }
283302
284− prop = _fdt_offset_ptr(fdt, offset);
303+ prop = fdt_offset_ptr_(fdt, offset);
285304
286305 if (lenp)
287306 *lenp = fdt32_to_cpu(prop->len);
@@ -289,23 +308,44 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt, · 1 unmodified line
289308 return prop;
290309 }
291310
292−const struct fdt_property *fdt_get_property_namelen(const void *fdt,
293− int offset,
294− const char *name,
295− int namelen, int *lenp)
311+const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
312+ int offset,
313+ int *lenp)
314+{
315+ /* Prior to version 16, properties may need realignment
316+ * and this API does not work. fdt_getprop_*() will, however. */
317+
318+ if (fdt_version(fdt) < 0x10) {
319+ if (lenp)
320+ *lenp = -FDT_ERR_BADVERSION;
321+ return NULL;
322+ }
323+
324+ return fdt_get_property_by_offset_(fdt, offset, lenp);
325+}
326+
327+static const struct fdt_property *fdt_get_property_namelen_(const void *fdt,
328+ int offset,
329+ const char *name,
330+ int namelen,
331+ int *lenp,
332+ int *poffset)
296333 {
297334 for (offset = fdt_first_property_offset(fdt, offset);
298335 (offset >= 0);
299336 (offset = fdt_next_property_offset(fdt, offset))) {
300337 const struct fdt_property *prop;
301338
302− if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) {
339+ if (!(prop = fdt_get_property_by_offset_(fdt, offset, lenp))) {
303340 offset = -FDT_ERR_INTERNAL;
304341 break;
305342 }
306− if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff),
307− name, namelen))
343+ if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff),
344+ name, namelen)) {
345+ if (poffset)
346+ *poffset = offset;
308347 return prop;
348+ }
309349 }
310350
311351 if (lenp)
@@ -313,6 +353,25 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt, · 1 unmodified line
313353 return NULL;
314354 }
315355
356+
357+const struct fdt_property *fdt_get_property_namelen(const void *fdt,
358+ int offset,
359+ const char *name,
360+ int namelen, int *lenp)
361+{
362+ /* Prior to version 16, properties may need realignment
363+ * and this API does not work. fdt_getprop_*() will, however. */
364+ if (fdt_version(fdt) < 0x10) {
365+ if (lenp)
366+ *lenp = -FDT_ERR_BADVERSION;
367+ return NULL;
368+ }
369+
370+ return fdt_get_property_namelen_(fdt, offset, name, namelen, lenp,
371+ NULL);
372+}
373+
374+
316375 const struct fdt_property *fdt_get_property(const void *fdt,
317376 int nodeoffset,
318377 const char *name, int *lenp)
@@ -324,12 +383,18 @@ const struct fdt_property *fdt_get_property(const void *fdt, · 5 unmodified lines
324383 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
325384 const char *name, int namelen, int *lenp)
326385 {
386+ int poffset;
327387 const struct fdt_property *prop;
328388
329− prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
389+ prop = fdt_get_property_namelen_(fdt, nodeoffset, name, namelen, lenp,
390+ &poffset);
330391 if (!prop)
331392 return NULL;
332393
394+ /* Handle realignment */
395+ if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 &&
396+ fdt32_to_cpu(prop->len) >= 8)
397+ return prop->data + 4;
333398 return prop->data;
334399 }
335400
@@ -338,11 +403,16 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, · 2 unmodified lines
338403 {
339404 const struct fdt_property *prop;
340405
341− prop = fdt_get_property_by_offset(fdt, offset, lenp);
406+ prop = fdt_get_property_by_offset_(fdt, offset, lenp);
342407 if (!prop)
343408 return NULL;
344409 if (namep)
345410 *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
411+
412+ /* Handle realignment */
413+ if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 &&
414+ fdt32_to_cpu(prop->len) >= 8)
415+ return prop->data + 4;
346416 return prop->data;
347417 }
348418
scripts/dtc/libfdt/fdt_rw.c+45−45
@@ -55,8 +55,8 @@ · 54 unmodified lines
5555
5656 #include "libfdt_internal.h"
5757
58−static int _fdt_blocks_misordered(const void *fdt,
59− int mem_rsv_size, int struct_size)
58+static int fdt_blocks_misordered_(const void *fdt,
59+ int mem_rsv_size, int struct_size)
6060 {
6161 return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
6262 || (fdt_off_dt_struct(fdt) <
@@ -67,13 +67,13 @@ static int _fdt_blocks_misordered(const void *fdt, · 4 unmodified lines
6767 (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
6868 }
6969
70−static int _fdt_rw_check_header(void *fdt)
70+static int fdt_rw_check_header_(void *fdt)
7171 {
7272 FDT_CHECK_HEADER(fdt);
7373
7474 if (fdt_version(fdt) < 17)
7575 return -FDT_ERR_BADVERSION;
76− if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
76+ if (fdt_blocks_misordered_(fdt, sizeof(struct fdt_reserve_entry),
7777 fdt_size_dt_struct(fdt)))
7878 return -FDT_ERR_BADLAYOUT;
7979 if (fdt_version(fdt) > 17)
@@ -84,20 +84,20 @@ static int _fdt_rw_check_header(void *fdt) · 4 unmodified lines
8484
8585 #define FDT_RW_CHECK_HEADER(fdt) \
8686 { \
87− int __err; \
88− if ((__err = _fdt_rw_check_header(fdt)) != 0) \
89− return __err; \
87+ int err_; \
88+ if ((err_ = fdt_rw_check_header_(fdt)) != 0) \
89+ return err_; \
9090 }
9191
92−static inline int _fdt_data_size(void *fdt)
92+static inline int fdt_data_size_(void *fdt)
9393 {
9494 return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
9595 }
9696
97−static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
97+static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen)
9898 {
9999 char *p = splicepoint;
100− char *end = (char *)fdt + _fdt_data_size(fdt);
100+ char *end = (char *)fdt + fdt_data_size_(fdt);
101101
102102 if (((p + oldlen) < p) || ((p + oldlen) > end))
103103 return -FDT_ERR_BADOFFSET;
@@ -109,12 +109,12 @@ static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen) · 5 unmodified lines
109109 return 0;
110110 }
111111
112−static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
112+static int fdt_splice_mem_rsv_(void *fdt, struct fdt_reserve_entry *p,
113113 int oldn, int newn)
114114 {
115115 int delta = (newn - oldn) * sizeof(*p);
116116 int err;
117− err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
117+ err = fdt_splice_(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
118118 if (err)
119119 return err;
120120 fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
@@ -122,13 +122,13 @@ static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p, · 1 unmodified line
122122 return 0;
123123 }
124124
125−static int _fdt_splice_struct(void *fdt, void *p,
125+static int fdt_splice_struct_(void *fdt, void *p,
126126 int oldlen, int newlen)
127127 {
128128 int delta = newlen - oldlen;
129129 int err;
130130
131− if ((err = _fdt_splice(fdt, p, oldlen, newlen)))
131+ if ((err = fdt_splice_(fdt, p, oldlen, newlen)))
132132 return err;
133133
134134 fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
@@ -136,20 +136,20 @@ static int _fdt_splice_struct(void *fdt, void *p, · 1 unmodified line
136136 return 0;
137137 }
138138
139−static int _fdt_splice_string(void *fdt, int newlen)
139+static int fdt_splice_string_(void *fdt, int newlen)
140140 {
141141 void *p = (char *)fdt
142142 + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
143143 int err;
144144
145− if ((err = _fdt_splice(fdt, p, 0, newlen)))
145+ if ((err = fdt_splice_(fdt, p, 0, newlen)))
146146 return err;
147147
148148 fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
149149 return 0;
150150 }
151151
152−static int _fdt_find_add_string(void *fdt, const char *s)
152+static int fdt_find_add_string_(void *fdt, const char *s)
153153 {
154154 char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
155155 const char *p;
@@ -157,13 +157,13 @@ static int _fdt_find_add_string(void *fdt, const char *s) · 1 unmodified line
157157 int len = strlen(s) + 1;
158158 int err;
159159
160− p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);
160+ p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
161161 if (p)
162162 /* found it */
163163 return (p - strtab);
164164
165165 new = strtab + fdt_size_dt_strings(fdt);
166− err = _fdt_splice_string(fdt, len);
166+ err = fdt_splice_string_(fdt, len);
167167 if (err)
168168 return err;
169169
@@ -178,8 +178,8 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) · 8 unmodified lines
178178
179179 FDT_RW_CHECK_HEADER(fdt);
180180
181− re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
182− err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
181+ re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt));
182+ err = fdt_splice_mem_rsv_(fdt, re, 0, 1);
183183 if (err)
184184 return err;
185185
@@ -190,17 +190,17 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) · 4 unmodified lines
190190
191191 int fdt_del_mem_rsv(void *fdt, int n)
192192 {
193− struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
193+ struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n);
194194
195195 FDT_RW_CHECK_HEADER(fdt);
196196
197197 if (n >= fdt_num_mem_rsv(fdt))
198198 return -FDT_ERR_NOTFOUND;
199199
200− return _fdt_splice_mem_rsv(fdt, re, 1, 0);
200+ return fdt_splice_mem_rsv_(fdt, re, 1, 0);
201201 }
202202
203−static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
203+static int fdt_resize_property_(void *fdt, int nodeoffset, const char *name,
204204 int len, struct fdt_property **prop)
205205 {
206206 int oldlen;
@@ -210,7 +210,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, · 3 unmodified lines
210210 if (!*prop)
211211 return oldlen;
212212
213− if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
213+ if ((err = fdt_splice_struct_(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
214214 FDT_TAGALIGN(len))))
215215 return err;
216216
@@ -218,7 +218,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
218218 return 0;
219219 }
220220
221−static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
221+static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
222222 int len, struct fdt_property **prop)
223223 {
224224 int proplen;
@@ -226,17 +226,17 @@ static int _fdt_add_property(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
226226 int namestroff;
227227 int err;
228228
229− if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
229+ if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
230230 return nextoffset;
231231
232− namestroff = _fdt_find_add_string(fdt, name);
232+ namestroff = fdt_find_add_string_(fdt, name);
233233 if (namestroff < 0)
234234 return namestroff;
235235
236− *prop = _fdt_offset_ptr_w(fdt, nextoffset);
236+ *prop = fdt_offset_ptr_w_(fdt, nextoffset);
237237 proplen = sizeof(**prop) + FDT_TAGALIGN(len);
238238
239− err = _fdt_splice_struct(fdt, *prop, 0, proplen);
239+ err = fdt_splice_struct_(fdt, *prop, 0, proplen);
240240 if (err)
241241 return err;
242242
@@ -260,7 +260,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name) · 17 unmodified lines
260260
261261 newlen = strlen(name);
262262
263− err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
263+ err = fdt_splice_struct_(fdt, namep, FDT_TAGALIGN(oldlen+1),
264264 FDT_TAGALIGN(newlen+1));
265265 if (err)
266266 return err;
@@ -277,9 +277,9 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, · 10 unmodified lines
277277
278278 FDT_RW_CHECK_HEADER(fdt);
279279
280− err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);
280+ err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop);
281281 if (err == -FDT_ERR_NOTFOUND)
282− err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
282+ err = fdt_add_property_(fdt, nodeoffset, name, len, &prop);
283283 if (err)
284284 return err;
285285
@@ -313,7 +313,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, · 27 unmodified lines
313313 prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
314314 if (prop) {
315315 newlen = len + oldlen;
316− err = _fdt_splice_struct(fdt, prop->data,
316+ err = fdt_splice_struct_(fdt, prop->data,
317317 FDT_TAGALIGN(oldlen),
318318 FDT_TAGALIGN(newlen));
319319 if (err)
@@ -321,7 +321,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
321321 prop->len = cpu_to_fdt32(newlen);
322322 memcpy(prop->data + oldlen, val, len);
323323 } else {
324− err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
324+ err = fdt_add_property_(fdt, nodeoffset, name, len, &prop);
325325 if (err)
326326 return err;
327327 memcpy(prop->data, val, len);
@@ -341,7 +341,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name) · 13 unmodified lines
341341 return len;
342342
343343 proplen = sizeof(*prop) + FDT_TAGALIGN(len);
344− return _fdt_splice_struct(fdt, prop, proplen, 0);
344+ return fdt_splice_struct_(fdt, prop, proplen, 0);
345345 }
346346
347347 int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@@ -369,10 +369,10 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, · 21 unmodified lines
369369 tag = fdt_next_tag(fdt, offset, &nextoffset);
370370 } while ((tag == FDT_PROP) || (tag == FDT_NOP));
371371
372− nh = _fdt_offset_ptr_w(fdt, offset);
372+ nh = fdt_offset_ptr_w_(fdt, offset);
373373 nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
374374
375− err = _fdt_splice_struct(fdt, nh, 0, nodelen);
375+ err = fdt_splice_struct_(fdt, nh, 0, nodelen);
376376 if (err)
377377 return err;
378378
@@ -396,15 +396,15 @@ int fdt_del_node(void *fdt, int nodeoffset) · 17 unmodified lines
396396
397397 FDT_RW_CHECK_HEADER(fdt);
398398
399− endoffset = _fdt_node_end_offset(fdt, nodeoffset);
399+ endoffset = fdt_node_end_offset_(fdt, nodeoffset);
400400 if (endoffset < 0)
401401 return endoffset;
402402
403− return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
403+ return fdt_splice_struct_(fdt, fdt_offset_ptr_w_(fdt, nodeoffset),
404404 endoffset - nodeoffset, 0);
405405 }
406406
407−static void _fdt_packblocks(const char *old, char *new,
407+static void fdt_packblocks_(const char *old, char *new,
408408 int mem_rsv_size, int struct_size)
409409 {
410410 int mem_rsv_off, struct_off, strings_off;
@@ -450,7 +450,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) · 39 unmodified lines
450450 return struct_size;
451451 }
452452
453− if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
453+ if (!fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) {
454454 /* no further work necessary */
455455 err = fdt_move(fdt, buf, bufsize);
456456 if (err)
@@ -478,7 +478,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) · 21 unmodified lines
478478 return -FDT_ERR_NOSPACE;
479479 }
480480
481− _fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
481+ fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size);
482482 memmove(buf, tmp, newsize);
483483
484484 fdt_set_magic(buf, FDT_MAGIC);
@@ -498,8 +498,8 @@ int fdt_pack(void *fdt) · 13 unmodified lines
498498
499499 mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
500500 * sizeof(struct fdt_reserve_entry);
501− _fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
502− fdt_set_totalsize(fdt, _fdt_data_size(fdt));
501+ fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
502+ fdt_set_totalsize(fdt, fdt_data_size_(fdt));
503503
504504 return 0;
505505 }
scripts/dtc/libfdt/fdt_sw.c+12−12
@@ -55,7 +55,7 @@ · 54 unmodified lines
5555
5656 #include "libfdt_internal.h"
5757
58−static int _fdt_sw_check_header(void *fdt)
58+static int fdt_sw_check_header_(void *fdt)
5959 {
6060 if (fdt_magic(fdt) != FDT_SW_MAGIC)
6161 return -FDT_ERR_BADMAGIC;
@@ -66,11 +66,11 @@ static int _fdt_sw_check_header(void *fdt) · 4 unmodified lines
6666 #define FDT_SW_CHECK_HEADER(fdt) \
6767 { \
6868 int err; \
69− if ((err = _fdt_sw_check_header(fdt)) != 0) \
69+ if ((err = fdt_sw_check_header_(fdt)) != 0) \
7070 return err; \
7171 }
7272
73−static void *_fdt_grab_space(void *fdt, size_t len)
73+static void *fdt_grab_space_(void *fdt, size_t len)
7474 {
7575 int offset = fdt_size_dt_struct(fdt);
7676 int spaceleft;
@@ -82,7 +82,7 @@ static void *_fdt_grab_space(void *fdt, size_t len) · 5 unmodified lines
8282 return NULL;
8383
8484 fdt_set_size_dt_struct(fdt, offset + len);
85− return _fdt_offset_ptr_w(fdt, offset);
85+ return fdt_offset_ptr_w_(fdt, offset);
8686 }
8787
8888 int fdt_create(void *buf, int bufsize)
@@ -174,7 +174,7 @@ int fdt_begin_node(void *fdt, const char *name) · 85 unmodified lines
174174
175175 FDT_SW_CHECK_HEADER(fdt);
176176
177− nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
177+ nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
178178 if (! nh)
179179 return -FDT_ERR_NOSPACE;
180180
@@ -189,7 +189,7 @@ int fdt_end_node(void *fdt) · 8 unmodified lines
189189
190190 FDT_SW_CHECK_HEADER(fdt);
191191
192− en = _fdt_grab_space(fdt, FDT_TAGSIZE);
192+ en = fdt_grab_space_(fdt, FDT_TAGSIZE);
193193 if (! en)
194194 return -FDT_ERR_NOSPACE;
195195
@@ -197,7 +197,7 @@ int fdt_end_node(void *fdt) · 1 unmodified line
197197 return 0;
198198 }
199199
200−static int _fdt_find_add_string(void *fdt, const char *s)
200+static int fdt_find_add_string_(void *fdt, const char *s)
201201 {
202202 char *strtab = (char *)fdt + fdt_totalsize(fdt);
203203 const char *p;
@@ -205,7 +205,7 @@ static int _fdt_find_add_string(void *fdt, const char *s) · 1 unmodified line
205205 int len = strlen(s) + 1;
206206 int struct_top, offset;
207207
208− p = _fdt_find_string(strtab - strtabsize, strtabsize, s);
208+ p = fdt_find_string_(strtab - strtabsize, strtabsize, s);
209209 if (p)
210210 return p - strtab;
211211
@@ -227,11 +227,11 @@ int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) · 15 unmodified lines
227227
228228 FDT_SW_CHECK_HEADER(fdt);
229229
230− nameoff = _fdt_find_add_string(fdt, name);
230+ nameoff = fdt_find_add_string_(fdt, name);
231231 if (nameoff == 0)
232232 return -FDT_ERR_NOSPACE;
233233
234− prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
234+ prop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
235235 if (! prop)
236236 return -FDT_ERR_NOSPACE;
237237
@@ -265,7 +265,7 @@ int fdt_finish(void *fdt) · 27 unmodified lines
265265 FDT_SW_CHECK_HEADER(fdt);
266266
267267 /* Add terminator */
268− end = _fdt_grab_space(fdt, sizeof(*end));
268+ end = fdt_grab_space_(fdt, sizeof(*end));
269269 if (! end)
270270 return -FDT_ERR_NOSPACE;
271271 *end = cpu_to_fdt32(FDT_END);
@@ -281,7 +281,7 @@ int fdt_finish(void *fdt) · 9 unmodified lines
281281 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
282282 if (tag == FDT_PROP) {
283283 struct fdt_property *prop =
284− _fdt_offset_ptr_w(fdt, offset);
284+ fdt_offset_ptr_w_(fdt, offset);
285285 int nameoff;
286286
287287 nameoff = fdt32_to_cpu(prop->nameoff);
scripts/dtc/libfdt/fdt_wip.c+5−5
@@ -93,7 +93,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, · 92 unmodified lines
9393 val, len);
9494 }
9595
96−static void _fdt_nop_region(void *start, int len)
96+static void fdt_nop_region_(void *start, int len)
9797 {
9898 fdt32_t *p;
9999
@@ -110,12 +110,12 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name) · 10 unmodified lines
110110 if (!prop)
111111 return len;
112112
113− _fdt_nop_region(prop, len + sizeof(*prop));
113+ fdt_nop_region_(prop, len + sizeof(*prop));
114114
115115 return 0;
116116 }
117117
118−int _fdt_node_end_offset(void *fdt, int offset)
118+int fdt_node_end_offset_(void *fdt, int offset)
119119 {
120120 int depth = 0;
121121
@@ -129,11 +129,11 @@ int fdt_nop_node(void *fdt, int nodeoffset) · 7 unmodified lines
129129 {
130130 int endoffset;
131131
132− endoffset = _fdt_node_end_offset(fdt, nodeoffset);
132+ endoffset = fdt_node_end_offset_(fdt, nodeoffset);
133133 if (endoffset < 0)
134134 return endoffset;
135135
136− _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
136+ fdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0),
137137 endoffset - nodeoffset);
138138 return 0;
139139 }
scripts/dtc/libfdt/libfdt.h+20−17
@@ -1,5 +1,5 @@
1−#ifndef _LIBFDT_H
2−#define _LIBFDT_H
1+#ifndef LIBFDT_H
2+#define LIBFDT_H
33 /*
44 * libfdt - Flat Device Tree manipulation
55 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -54,7 +54,7 @@ · 48 unmodified lines
5454 #include "libfdt_env.h"
5555 #include "fdt.h"
5656
57−#define FDT_FIRST_SUPPORTED_VERSION 0x10
57+#define FDT_FIRST_SUPPORTED_VERSION 0x02
5858 #define FDT_LAST_SUPPORTED_VERSION 0x11
5959
6060 /* Error codes: informative error codes */
@@ -225,23 +225,23 @@ int fdt_next_subnode(const void *fdt, int offset); · 164 unmodified lines
225225 #define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
226226 #define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
227227
228−#define __fdt_set_hdr(name) \
228+#define fdt_set_hdr_(name) \
229229 static inline void fdt_set_##name(void *fdt, uint32_t val) \
230230 { \
231231 struct fdt_header *fdth = (struct fdt_header *)fdt; \
232232 fdth->name = cpu_to_fdt32(val); \
233233 }
234−__fdt_set_hdr(magic);
235−__fdt_set_hdr(totalsize);
236−__fdt_set_hdr(off_dt_struct);
237−__fdt_set_hdr(off_dt_strings);
238−__fdt_set_hdr(off_mem_rsvmap);
239−__fdt_set_hdr(version);
240−__fdt_set_hdr(last_comp_version);
241−__fdt_set_hdr(boot_cpuid_phys);
242−__fdt_set_hdr(size_dt_strings);
243−__fdt_set_hdr(size_dt_struct);
244−#undef __fdt_set_hdr
234+fdt_set_hdr_(magic);
235+fdt_set_hdr_(totalsize);
236+fdt_set_hdr_(off_dt_struct);
237+fdt_set_hdr_(off_dt_strings);
238+fdt_set_hdr_(off_mem_rsvmap);
239+fdt_set_hdr_(version);
240+fdt_set_hdr_(last_comp_version);
241+fdt_set_hdr_(boot_cpuid_phys);
242+fdt_set_hdr_(size_dt_strings);
243+fdt_set_hdr_(size_dt_struct);
244+#undef fdt_set_hdr_
245245
246246 /**
247247 * fdt_check_header - sanity check a device tree or possible device tree
@@ -527,6 +527,9 @@ int fdt_next_property_offset(const void *fdt, int offset); · 279 unmodified lines
527527 * offset. If lenp is non-NULL, the length of the property value is
528528 * also returned, in the integer pointed to by lenp.
529529 *
530+ * Note that this code only works on device tree versions >= 16. fdt_getprop()
531+ * works on all versions.
532+ *
530533 * returns:
531534 * pointer to the structure representing the property
532535 * if lenp is non-NULL, *lenp contains the length of the property
@@ -1449,7 +1452,7 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, · 916 unmodified lines
14491452 const void *val, int len);
14501453
14511454 /**
1452− * fdt_setprop _placeholder - allocate space for a property
1455+ * fdt_setprop_placeholder - allocate space for a property
14531456 * @fdt: pointer to the device tree blob
14541457 * @nodeoffset: offset of the node whose property to change
14551458 * @name: name of the property to change
@@ -1896,4 +1899,4 @@ int fdt_overlay_apply(void *fdt, void *fdto); · 440 unmodified lines
18961899
18971900 const char *fdt_strerror(int errval);
18981901
1899−#endif /* _LIBFDT_H */
1902+#endif /* LIBFDT_H */
scripts/dtc/libfdt/libfdt_env.h+30−3
@@ -1,5 +1,5 @@
1−#ifndef _LIBFDT_ENV_H
2−#define _LIBFDT_ENV_H
1+#ifndef LIBFDT_ENV_H
2+#define LIBFDT_ENV_H
33 /*
44 * libfdt - Flat Device Tree manipulation
55 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -109,4 +109,31 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x) · 103 unmodified lines
109109 #undef CPU_TO_FDT16
110110 #undef EXTRACT_BYTE
111111
112−#endif /* _LIBFDT_ENV_H */
112+#ifdef __APPLE__
113+#include <AvailabilityMacros.h>
114+
115+/* strnlen() is not available on Mac OS < 10.7 */
116+# if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \
117+ MAC_OS_X_VERSION_10_7)
118+
119+#define strnlen fdt_strnlen
120+
121+/*
122+ * fdt_strnlen: returns the length of a string or max_count - which ever is
123+ * smallest.
124+ * Input 1 string: the string whose size is to be determined
125+ * Input 2 max_count: the maximum value returned by this function
126+ * Output: length of the string or max_count (the smallest of the two)
127+ */
128+static inline size_t fdt_strnlen(const char *string, size_t max_count)
129+{
130+ const char *p = memchr(string, 0, max_count);
131+ return p ? p - string : max_count;
132+}
133+
134+#endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED <
135+ MAC_OS_X_VERSION_10_7) */
136+
137+#endif /* __APPLE__ */
138+
139+#endif /* LIBFDT_ENV_H */
scripts/dtc/libfdt/libfdt_internal.h+16−16
@@ -1,5 +1,5 @@
1−#ifndef _LIBFDT_INTERNAL_H
2−#define _LIBFDT_INTERNAL_H
1+#ifndef LIBFDT_INTERNAL_H
2+#define LIBFDT_INTERNAL_H
33 /*
44 * libfdt - Flat Device Tree manipulation
55 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -57,27 +57,27 @@ · 51 unmodified lines
5757
5858 #define FDT_CHECK_HEADER(fdt) \
5959 { \
60− int __err; \
61− if ((__err = fdt_check_header(fdt)) != 0) \
62− return __err; \
60+ int err_; \
61+ if ((err_ = fdt_check_header(fdt)) != 0) \
62+ return err_; \
6363 }
6464
65−int _fdt_check_node_offset(const void *fdt, int offset);
66−int _fdt_check_prop_offset(const void *fdt, int offset);
67−const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
68−int _fdt_node_end_offset(void *fdt, int nodeoffset);
65+int fdt_check_node_offset_(const void *fdt, int offset);
66+int fdt_check_prop_offset_(const void *fdt, int offset);
67+const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
68+int fdt_node_end_offset_(void *fdt, int nodeoffset);
6969
70−static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
70+static inline const void *fdt_offset_ptr_(const void *fdt, int offset)
7171 {
7272 return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
7373 }
7474
75−static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
75+static inline void *fdt_offset_ptr_w_(void *fdt, int offset)
7676 {
77− return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
77+ return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset);
7878 }
7979
80−static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
80+static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n)
8181 {
8282 const struct fdt_reserve_entry *rsv_table =
8383 (const struct fdt_reserve_entry *)
@@ -85,11 +85,11 @@ static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int · 1 unmodified line
8585
8686 return rsv_table + n;
8787 }
88−static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
88+static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
8989 {
90− return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
90+ return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
9191 }
9292
9393 #define FDT_SW_MAGIC (~FDT_MAGIC)
9494
95−#endif /* _LIBFDT_INTERNAL_H */
95+#endif /* LIBFDT_INTERNAL_H */
scripts/dtc/livetree.c+7−3
@@ -216,7 +216,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) · 215 unmodified lines
216216 return old_node;
217217 }
218218
219−void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
219+struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
220220 {
221221 static unsigned int next_orphan_fragment = 0;
222222 struct node *node;
@@ -236,6 +236,7 @@ void add_orphan_node(struct node *dt, struct node *new_node, char *ref) · 13 unmodified lines
236236 name_node(node, name);
237237
238238 add_child(dt, node);
239+ return dt;
239240 }
240241
241242 struct node *chain_node(struct node *first, struct node *list)
@@ -507,7 +508,7 @@ struct node *get_node_by_path(struct node *tree, const char *path) · 265 unmodified lines
507508
508509 for_each_child(tree, child) {
509510 if (p && (strlen(child->name) == p-path) &&
510− strneq(path, child->name, p-path))
511+ strprefixeq(path, p - path, child->name))
511512 return get_node_by_path(child, p+1);
512513 else if (!p && streq(path, child->name))
513514 return child;
@@ -540,7 +541,10 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle) · 26 unmodified lines
540541 {
541542 struct node *child, *node;
542543
543− assert((phandle != 0) && (phandle != -1));
544+ if ((phandle == 0) || (phandle == -1)) {
545+ assert(generate_fixups);
546+ return NULL;
547+ }
544548
545549 if (tree->phandle == phandle) {
546550 if (tree->deleted)
scripts/dtc/srcpos.c+0−5
@@ -209,8 +209,6 @@ struct srcpos srcpos_empty = { · 208 unmodified lines
209209 .file = NULL,
210210 };
211211
212−#define TAB_SIZE 8
213−
214212 void srcpos_update(struct srcpos *pos, const char *text, int len)
215213 {
216214 int i;
@@ -224,9 +222,6 @@ void srcpos_update(struct srcpos *pos, const char *text, int len) · 7 unmodified lines
224222 if (text[i] == '\n') {
225223 current_srcfile->lineno++;
226224 current_srcfile->colno = 1;
227− } else if (text[i] == '\t') {
228− current_srcfile->colno =
229− ALIGN(current_srcfile->colno, TAB_SIZE);
230225 } else {
231226 current_srcfile->colno++;
232227 }
scripts/dtc/srcpos.h+3−3
@@ -17,8 +17,8 @@ · 16 unmodified lines
1717 * USA
1818 */
1919
20−#ifndef _SRCPOS_H_
21−#define _SRCPOS_H_
20+#ifndef SRCPOS_H
21+#define SRCPOS_H
2222
2323 #include <stdio.h>
2424 #include <stdbool.h>
@@ -114,4 +114,4 @@ extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix, · 89 unmodified lines
114114
115115 extern void srcpos_set_line(char *f, int l);
116116
117−#endif /* _SRCPOS_H_ */
117+#endif /* SRCPOS_H */
scripts/dtc/util.h+6−3
@@ -1,5 +1,5 @@
1−#ifndef _UTIL_H
2−#define _UTIL_H
1+#ifndef UTIL_H
2+#define UTIL_H
33
44 #include <stdarg.h>
55 #include <stdbool.h>
@@ -35,6 +35,9 @@ · 29 unmodified lines
3535
3636 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
3737
38+#define stringify(s) stringify_(s)
39+#define stringify_(s) #s
40+
3841 static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
3942 {
4043 va_list ap;
@@ -260,4 +263,4 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis, · 219 unmodified lines
260263 case 'V': util_version(); \
261264 case '?': usage("unknown option");
262265
263−#endif /* _UTIL_H */
266+#endif /* UTIL_H */
scripts/dtc/version_gen.h+1−1
@@ -1 +1 @@
1−#define DTC_VERSION "DTC 1.4.5-gc1e55a55"
1+#define DTC_VERSION "DTC 1.4.6-gaadd0b65"