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

Showing the changes to scripts (20 of 21 files). Show all

Unified · Split

20 files
  1. scripts/dtc/checks.c +290 −149
  2. scripts/dtc/dtc-parser.y +11 −6
  3. scripts/dtc/dtc.c +3 −4
  4. scripts/dtc/dtc.h +6 −5
  5. scripts/dtc/flattree.c +1 −1
  6. scripts/dtc/libfdt/fdt.c +8 −5
  7. scripts/dtc/libfdt/fdt.h +3 −3
  8. scripts/dtc/libfdt/fdt_overlay.c +51 −0
  9. scripts/dtc/libfdt/fdt_ro.c +101 −31
  10. scripts/dtc/libfdt/fdt_rw.c +45 −45
  11. scripts/dtc/libfdt/fdt_sw.c +12 −12
  12. scripts/dtc/libfdt/fdt_wip.c +5 −5
  13. scripts/dtc/libfdt/libfdt.h +20 −17
  14. scripts/dtc/libfdt/libfdt_env.h +30 −3
  15. scripts/dtc/libfdt/libfdt_internal.h +16 −16
  16. scripts/dtc/livetree.c +7 −3
  17. scripts/dtc/srcpos.c +0 −5
  18. scripts/dtc/srcpos.h +3 −3
  19. scripts/dtc/util.h +6 −3
  20. scripts/dtc/version_gen.h +1 −1
scripts/dtc/checks.c+290−149
@@ -53,26 +53,28 @@ struct check { · 52 unmodified lines
53 struct check **prereq;53 struct check **prereq;
54};54};
55 55
56#define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \56#define CHECK_ENTRY(nm_, fn_, d_, w_, e_, ...) \
57 static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \57 static struct check *nm_##_prereqs[] = { __VA_ARGS__ }; \
58 static struct check _nm = { \58 static struct check nm_ = { \
59 .name = #_nm, \59 .name = #nm_, \
60 .fn = (_fn), \60 .fn = (fn_), \
61 .data = (_d), \61 .data = (d_), \
62 .warn = (_w), \62 .warn = (w_), \
63 .error = (_e), \63 .error = (e_), \
64 .status = UNCHECKED, \64 .status = UNCHECKED, \
65 .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \65 .num_prereqs = ARRAY_SIZE(nm_##_prereqs), \
66 .prereq = _nm##_prereqs, \66 .prereq = nm_##_prereqs, \
67 };67 };
68#define WARNING(_nm, _fn, _d, ...) \68#define WARNING(nm_, fn_, d_, ...) \
69 CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__)69 CHECK_ENTRY(nm_, fn_, d_, true, false, __VA_ARGS__)
70#define ERROR(_nm, _fn, _d, ...) \70#define ERROR(nm_, fn_, d_, ...) \
71 CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__)71 CHECK_ENTRY(nm_, fn_, d_, false, true, __VA_ARGS__)
72#define CHECK(_nm, _fn, _d, ...) \72#define CHECK(nm_, fn_, d_, ...) \
73 CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)73 CHECK_ENTRY(nm_, fn_, d_, false, false, __VA_ARGS__)
74 74
75static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,75static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
76 struct node *node,
77 struct property *prop,
76 const char *fmt, ...)78 const char *fmt, ...)
77{79{
78 va_list ap;80 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
83 fprintf(stderr, "%s: %s (%s): ",85 fprintf(stderr, "%s: %s (%s): ",
84 strcmp(dti->outname, "-") ? dti->outname : "<stdout>",86 strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
85 (c->error) ? "ERROR" : "Warning", c->name);87 (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 }
86 vfprintf(stderr, fmt, ap);94 vfprintf(stderr, fmt, ap);
87 fprintf(stderr, "\n");95 fprintf(stderr, "\n");
88 }96 }
89 va_end(ap);97 va_end(ap);
90}98}
91 99
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, ...) \
93 do { \108 do { \
94 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \109 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
95 (c)->status = FAILED; \110 (c)->status = FAILED; \
96 check_msg((c), dti, __VA_ARGS__); \111 check_msg((c), dti, node, prop, __VA_ARGS__); \
97 } while (0)112 } while (0)
98 113
114
99static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)115static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
100{116{
101 struct node *child;117 struct node *child;
@@ -126,7 +142,7 @@ static bool run_check(struct check *c, struct dt_info *dti) · 24 unmodified lines
126 error = error || run_check(prq, dti);142 error = error || run_check(prq, dti);
127 if (prq->status != PASSED) {143 if (prq->status != PASSED) {
128 c->status = PREREQ;144 c->status = PREREQ;
129 check_msg(c, dti, "Failed prerequisite '%s'",145 check_msg(c, dti, NULL, NULL, "Failed prerequisite '%s'",
130 c->prereq[i]->name);146 c->prereq[i]->name);
131 }147 }
132 }148 }
@@ -156,7 +172,7 @@ out: · 23 unmodified lines
156static inline void check_always_fail(struct check *c, struct dt_info *dti,172static inline void check_always_fail(struct check *c, struct dt_info *dti,
157 struct node *node)173 struct node *node)
158{174{
159 FAIL(c, dti, "always_fail check");175 FAIL(c, dti, node, "always_fail check");
160}176}
161CHECK(always_fail, check_always_fail, NULL);177CHECK(always_fail, check_always_fail, NULL);
162 178
@@ -171,14 +187,42 @@ static void check_is_string(struct check *c, struct dt_info *dti, · 8 unmodified lines
171 return; /* Not present, assumed ok */187 return; /* Not present, assumed ok */
172 188
173 if (!data_is_one_string(prop->val))189 if (!data_is_one_string(prop->val))
174 FAIL(c, dti, "\"%s\" property in %s is not a string",190 FAIL_PROP(c, dti, node, prop, "property is not a string");
175 propname, node->fullpath);
176}191}
177#define WARNING_IF_NOT_STRING(nm, propname) \192#define WARNING_IF_NOT_STRING(nm, propname) \
178 WARNING(nm, check_is_string, (propname))193 WARNING(nm, check_is_string, (propname))
179#define ERROR_IF_NOT_STRING(nm, propname) \194#define ERROR_IF_NOT_STRING(nm, propname) \
180 ERROR(nm, check_is_string, (propname))195 ERROR(nm, check_is_string, (propname))
181 196
197static 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
182static void check_is_cell(struct check *c, struct dt_info *dti,226static void check_is_cell(struct check *c, struct dt_info *dti,
183 struct node *node)227 struct node *node)
184{228{
@@ -190,8 +234,7 @@ static void check_is_cell(struct check *c, struct dt_info *dti, · 5 unmodified lines
190 return; /* Not present, assumed ok */234 return; /* Not present, assumed ok */
191 235
192 if (prop->val.len != sizeof(cell_t))236 if (prop->val.len != sizeof(cell_t))
193 FAIL(c, dti, "\"%s\" property in %s is not a single cell",237 FAIL_PROP(c, dti, node, prop, "property is not a single cell");
194 propname, node->fullpath);
195}238}
196#define WARNING_IF_NOT_CELL(nm, propname) \239#define WARNING_IF_NOT_CELL(nm, propname) \
197 WARNING(nm, check_is_cell, (propname))240 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
212 child2;255 child2;
213 child2 = child2->next_sibling)256 child2 = child2->next_sibling)
214 if (streq(child->name, child2->name))257 if (streq(child->name, child2->name))
215 FAIL(c, dti, "Duplicate node name %s",258 FAIL(c, dti, node, "Duplicate node name");
216 child->fullpath);
217}259}
218ERROR(duplicate_node_names, check_duplicate_node_names, NULL);260ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
219 261
@@ -227,8 +269,7 @@ static void check_duplicate_property_names(struct check *c, struct dt_info *dti, · 7 unmodified lines
227 if (prop2->deleted)269 if (prop2->deleted)
228 continue;270 continue;
229 if (streq(prop->name, prop2->name))271 if (streq(prop->name, prop2->name))
230 FAIL(c, dti, "Duplicate property name %s in %s",272 FAIL_PROP(c, dti, node, prop, "Duplicate property name");
231 prop->name, node->fullpath);
232 }273 }
233 }274 }
234}275}
@@ -246,8 +287,8 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti, · 11 unmodified lines
246 int n = strspn(node->name, c->data);287 int n = strspn(node->name, c->data);
247 288
248 if (n < strlen(node->name))289 if (n < strlen(node->name))
249 FAIL(c, dti, "Bad character '%c' in node %s",290 FAIL(c, dti, node, "Bad character '%c' in node name",
250 node->name[n], node->fullpath);291 node->name[n]);
251}292}
252ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");293ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
253 294
@@ -257,8 +298,8 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, · 3 unmodified lines
257 int n = strspn(node->name, c->data);298 int n = strspn(node->name, c->data);
258 299
259 if (n < node->basenamelen)300 if (n < node->basenamelen)
260 FAIL(c, dti, "Character '%c' not recommended in node %s",301 FAIL(c, dti, node, "Character '%c' not recommended in node name",
261 node->name[n], node->fullpath);302 node->name[n]);
262}303}
263CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT);304CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT);
264 305
@@ -266,8 +307,7 @@ static void check_node_name_format(struct check *c, struct dt_info *dti, · 1 unmodified line
266 struct node *node)307 struct node *node)
267{308{
268 if (strchr(get_unitname(node), '@'))309 if (strchr(get_unitname(node), '@'))
269 FAIL(c, dti, "Node %s has multiple '@' characters in name",310 FAIL(c, dti, node, "multiple '@' characters in node name");
270 node->fullpath);
271}311}
272ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);312ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
273 313
@@ -285,12 +325,10 @@ static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, · 11 unmodified lines
285 325
286 if (prop) {326 if (prop) {
287 if (!unitname[0])327 if (!unitname[0])
288 FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name",328 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name");
289 node->fullpath);
290 } else {329 } else {
291 if (unitname[0])330 if (unitname[0])
292 FAIL(c, dti, "Node %s has a unit name, but no reg property",331 FAIL(c, dti, node, "node has a unit name, but no reg property");
293 node->fullpath);
294 }332 }
295}333}
296WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL);334WARNING(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
304 int n = strspn(prop->name, c->data);342 int n = strspn(prop->name, c->data);
305 343
306 if (n < strlen(prop->name))344 if (n < strlen(prop->name))
307 FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s",345 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name",
308 prop->name[n], prop->name, node->fullpath);346 prop->name[n]);
309 }347 }
310}348}
311ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);349ERROR(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
336 n = strspn(name, c->data);374 n = strspn(name, c->data);
337 }375 }
338 if (n < strlen(name))376 if (n < strlen(name))
339 FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s",377 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name",
340 name[n], prop->name, node->fullpath);378 name[n]);
341 }379 }
342}380}
343CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT);381CHECK(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
370 return;408 return;
371 409
372 if ((othernode != node) || (otherprop != prop) || (othermark != mark))410 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
373 FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT411 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT
374 " and " DESCLABEL_FMT,412 " and " DESCLABEL_FMT,
375 label, DESCLABEL_ARGS(node, prop, mark),413 label, DESCLABEL_ARGS(node, prop, mark),
376 DESCLABEL_ARGS(othernode, otherprop, othermark));414 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
410 return 0;448 return 0;
411 449
412 if (prop->val.len != sizeof(cell_t)) {450 if (prop->val.len != sizeof(cell_t)) {
413 FAIL(c, dti, "%s has bad length (%d) %s property",451 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property",
414 node->fullpath, prop->val.len, prop->name);452 prop->val.len, prop->name);
415 return 0;453 return 0;
416 }454 }
417 455
@@ -422,8 +460,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 4 unmodified lines
422 /* "Set this node's phandle equal to some460 /* "Set this node's phandle equal to some
423 * other node's phandle". That's nonsensical461 * other node's phandle". That's nonsensical
424 * by construction. */ {462 * by construction. */ {
425 FAIL(c, dti, "%s in %s is a reference to another node",463 FAIL(c, dti, node, "%s is a reference to another node",
426 prop->name, node->fullpath);464 prop->name);
427 }465 }
428 /* But setting this node's phandle equal to its own466 /* But setting this node's phandle equal to its own
429 * phandle is allowed - that means allocate a unique467 * 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
436 phandle = propval_cell(prop);474 phandle = propval_cell(prop);
437 475
438 if ((phandle == 0) || (phandle == -1)) {476 if ((phandle == 0) || (phandle == -1)) {
439 FAIL(c, dti, "%s has bad value (0x%x) in %s property",477 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property",
440 node->fullpath, phandle, prop->name);478 phandle, prop->name);
441 return 0;479 return 0;
442 }480 }
443 481
@@ -463,16 +501,16 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti, · 19 unmodified lines
463 return;501 return;
464 502
465 if (linux_phandle && phandle && (phandle != linux_phandle))503 if (linux_phandle && phandle && (phandle != linux_phandle))
466 FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'"504 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'"
467 " properties", node->fullpath);505 " properties");
468 506
469 if (linux_phandle && !phandle)507 if (linux_phandle && !phandle)
470 phandle = linux_phandle;508 phandle = linux_phandle;
471 509
472 other = get_node_by_phandle(root, phandle);510 other = get_node_by_phandle(root, phandle);
473 if (other && (other != node)) {511 if (other && (other != node)) {
474 FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)",512 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)",
475 node->fullpath, phandle, other->fullpath);513 phandle, other->fullpath);
476 return;514 return;
477 }515 }
478 516
@@ -496,8 +534,8 @@ static void check_name_properties(struct check *c, struct dt_info *dti, · 17 unmodified lines
496 534
497 if ((prop->val.len != node->basenamelen+1)535 if ((prop->val.len != node->basenamelen+1)
498 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {536 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
499 FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead"537 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead"
500 " of base node name)", node->fullpath, prop->val.val);538 " of base node name)", prop->val.val);
501 } else {539 } else {
502 /* The name property is correct, and therefore redundant.540 /* The name property is correct, and therefore redundant.
503 * Delete it */541 * Delete it */
@@ -531,7 +569,7 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti, · 27 unmodified lines
531 refnode = get_node_by_ref(dt, m->ref);569 refnode = get_node_by_ref(dt, m->ref);
532 if (! refnode) {570 if (! refnode) {
533 if (!(dti->dtsflags & DTSF_PLUGIN))571 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 "
535 "label \"%s\"\n", m->ref);573 "label \"%s\"\n", m->ref);
536 else /* mark the entry as unresolved */574 else /* mark the entry as unresolved */
537 *((fdt32_t *)(prop->val.val + m->offset)) =575 *((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
563 601
564 refnode = get_node_by_ref(dt, m->ref);602 refnode = get_node_by_ref(dt, m->ref);
565 if (!refnode) {603 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",
567 m->ref);605 m->ref);
568 continue;606 continue;
569 }607 }
@@ -586,6 +624,45 @@ WARNING_IF_NOT_CELL(interrupt_cells_is_cell, "#interrupt-cells"); · 16 unmodified lines
586WARNING_IF_NOT_STRING(device_type_is_string, "device_type");624WARNING_IF_NOT_STRING(device_type_is_string, "device_type");
587WARNING_IF_NOT_STRING(model_is_string, "model");625WARNING_IF_NOT_STRING(model_is_string, "model");
588WARNING_IF_NOT_STRING(status_is_string, "status");626WARNING_IF_NOT_STRING(status_is_string, "status");
627WARNING_IF_NOT_STRING(label_is_string, "label");
628
629WARNING_IF_NOT_STRING_LIST(compatible_is_string_list, "compatible");
630
631static 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}
645WARNING(names_is_string_list, check_names_is_string_list, NULL);
646
647static 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}
665WARNING(alias_paths, check_alias_paths, NULL);
589 666
590static void fixup_addr_size_cells(struct check *c, struct dt_info *dti,667static void fixup_addr_size_cells(struct check *c, struct dt_info *dti,
591 struct node *node)668 struct node *node)
@@ -622,21 +699,21 @@ static void check_reg_format(struct check *c, struct dt_info *dti, · 30 unmodified lines
622 return; /* No "reg", that's fine */699 return; /* No "reg", that's fine */
623 700
624 if (!node->parent) {701 if (!node->parent) {
625 FAIL(c, dti, "Root node has a \"reg\" property");702 FAIL(c, dti, node, "Root node has a \"reg\" property");
626 return;703 return;
627 }704 }
628 705
629 if (prop->val.len == 0)706 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");
631 708
632 addr_cells = node_addr_cells(node->parent);709 addr_cells = node_addr_cells(node->parent);
633 size_cells = node_size_cells(node->parent);710 size_cells = node_size_cells(node->parent);
634 entrylen = (addr_cells + size_cells) * sizeof(cell_t);711 entrylen = (addr_cells + size_cells) * sizeof(cell_t);
635 712
636 if (!entrylen || (prop->val.len % entrylen) != 0)713 if (!entrylen || (prop->val.len % entrylen) != 0)
637 FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) "714 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) "
638 "(#address-cells == %d, #size-cells == %d)",715 "(#address-cells == %d, #size-cells == %d)",
639 node->fullpath, prop->val.len, addr_cells, size_cells);716 prop->val.len, addr_cells, size_cells);
640}717}
641WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);718WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);
642 719
@@ -651,7 +728,7 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 8 unmodified lines
651 return;728 return;
652 729
653 if (!node->parent) {730 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");
655 return;732 return;
656 }733 }
657 734
@@ -663,20 +740,20 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 5 unmodified lines
663 740
664 if (prop->val.len == 0) {741 if (prop->val.len == 0) {
665 if (p_addr_cells != c_addr_cells)742 if (p_addr_cells != c_addr_cells)
666 FAIL(c, dti, "%s has empty \"ranges\" property but its "743 FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
667 "#address-cells (%d) differs from %s (%d)",744 "#address-cells (%d) differs from %s (%d)",
668 node->fullpath, c_addr_cells, node->parent->fullpath,745 c_addr_cells, node->parent->fullpath,
669 p_addr_cells);746 p_addr_cells);
670 if (p_size_cells != c_size_cells)747 if (p_size_cells != c_size_cells)
671 FAIL(c, dti, "%s has empty \"ranges\" property but its "748 FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
672 "#size-cells (%d) differs from %s (%d)",749 "#size-cells (%d) differs from %s (%d)",
673 node->fullpath, c_size_cells, node->parent->fullpath,750 c_size_cells, node->parent->fullpath,
674 p_size_cells);751 p_size_cells);
675 } else if ((prop->val.len % entrylen) != 0) {752 } else if ((prop->val.len % entrylen) != 0) {
676 FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) "753 FAIL_PROP(c, dti, node, prop, "\"ranges\" property has invalid length (%d bytes) "
677 "(parent #address-cells == %d, child #address-cells == %d, "754 "(parent #address-cells == %d, child #address-cells == %d, "
678 "#size-cells == %d)", node->fullpath, prop->val.len,755 "#size-cells == %d)", prop->val.len,
679 p_addr_cells, c_addr_cells, c_size_cells);756 p_addr_cells, c_addr_cells, c_size_cells);
680 }757 }
681}758}
682WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);759WARNING(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
696 773
697 node->bus = &pci_bus;774 node->bus = &pci_bus;
698 775
699 if (!strneq(node->name, "pci", node->basenamelen) &&776 if (!strprefixeq(node->name, node->basenamelen, "pci") &&
700 !strneq(node->name, "pcie", node->basenamelen))777 !strprefixeq(node->name, node->basenamelen, "pcie"))
701 FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"",778 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\"");
702 node->fullpath);
703 779
704 prop = get_property(node, "ranges");780 prop = get_property(node, "ranges");
705 if (!prop)781 if (!prop)
706 FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)",782 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)");
707 node->fullpath);
708 783
709 if (node_addr_cells(node) != 3)784 if (node_addr_cells(node) != 3)
710 FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge",785 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
711 node->fullpath);
712 if (node_size_cells(node) != 2)786 if (node_size_cells(node) != 2)
713 FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge",787 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
714 node->fullpath);
715 788
716 prop = get_property(node, "bus-range");789 prop = get_property(node, "bus-range");
717 if (!prop) {790 if (!prop) {
718 FAIL(c, dti, "Node %s missing bus-range for PCI bridge",791 FAIL(c, dti, node, "missing bus-range for PCI bridge");
719 node->fullpath);
720 return;792 return;
721 }793 }
722 if (prop->val.len != (sizeof(cell_t) * 2)) {794 if (prop->val.len != (sizeof(cell_t) * 2)) {
723 FAIL(c, dti, "Node %s bus-range must be 2 cells",795 FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
724 node->fullpath);
725 return;796 return;
726 }797 }
727 cells = (cell_t *)prop->val.val;798 cells = (cell_t *)prop->val.val;
728 if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1]))799 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",800 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
730 node->fullpath);
731 if (fdt32_to_cpu(cells[1]) > 0xff)801 if (fdt32_to_cpu(cells[1]) > 0xff)
732 FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256",802 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256");
733 node->fullpath);
734}803}
735WARNING(pci_bridge, check_pci_bridge, NULL,804WARNING(pci_bridge, check_pci_bridge, NULL,
736 &device_type_is_string, &addr_size_cells);805 &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
760 max_bus = fdt32_to_cpu(cells[0]);829 max_bus = fdt32_to_cpu(cells[0]);
761 }830 }
762 if ((bus_num < min_bus) || (bus_num > max_bus))831 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)",832 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
764 node->fullpath, bus_num, min_bus, max_bus);833 bus_num, min_bus, max_bus);
765}834}
766WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, &reg_format, &pci_bridge);835WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, &reg_format, &pci_bridge);
767 836
@@ -778,25 +847,22 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no · 10 unmodified lines
778 847
779 prop = get_property(node, "reg");848 prop = get_property(node, "reg");
780 if (!prop) {849 if (!prop) {
781 FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath);850 FAIL(c, dti, node, "missing PCI reg property");
782 return;851 return;
783 }852 }
784 853
785 cells = (cell_t *)prop->val.val;854 cells = (cell_t *)prop->val.val;
786 if (cells[1] || cells[2])855 if (cells[1] || cells[2])
787 FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0",856 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
788 node->fullpath);
789 857
790 reg = fdt32_to_cpu(cells[0]);858 reg = fdt32_to_cpu(cells[0]);
791 dev = (reg & 0xf800) >> 11;859 dev = (reg & 0xf800) >> 11;
792 func = (reg & 0x700) >> 8;860 func = (reg & 0x700) >> 8;
793 861
794 if (reg & 0xff000000)862 if (reg & 0xff000000)
795 FAIL(c, dti, "Node %s PCI reg address is not configuration space",863 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space");
796 node->fullpath);
797 if (reg & 0x000000ff)864 if (reg & 0x000000ff)
798 FAIL(c, dti, "Node %s PCI reg config space address register number must be 0",865 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0");
799 node->fullpath);
800 866
801 if (func == 0) {867 if (func == 0) {
802 snprintf(unit_addr, sizeof(unit_addr), "%x", dev);868 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
808 if (streq(unitname, unit_addr))874 if (streq(unitname, unit_addr))
809 return;875 return;
810 876
811 FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"",877 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"",
812 node->fullpath, unit_addr);878 unit_addr);
813}879}
814WARNING(pci_device_reg, check_pci_device_reg, NULL, &reg_format, &pci_bridge);880WARNING(pci_device_reg, check_pci_device_reg, NULL, &reg_format, &pci_bridge);
815 881
@@ -828,7 +894,7 @@ static bool node_is_compatible(struct node *node, const char *compat) · 12 unmodified lines
828 894
829 for (str = prop->val.val, end = str + prop->val.len; str < end;895 for (str = prop->val.val, end = str + prop->val.len; str < end;
830 str += strnlen(str, end - str) + 1) {896 str += strnlen(str, end - str) + 1) {
831 if (strneq(str, compat, end - str))897 if (strprefixeq(str, end - str, compat))
832 return true;898 return true;
833 }899 }
834 return false;900 return false;
@@ -865,7 +931,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no · 30 unmodified lines
865 931
866 if (!cells) {932 if (!cells) {
867 if (node->parent->parent && !(node->bus == &simple_bus))933 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");
869 return;935 return;
870 }936 }
871 937
@@ -875,8 +941,8 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no · 3 unmodified lines
875 941
876 snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);942 snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);
877 if (!streq(unitname, unit_addr))943 if (!streq(unitname, unit_addr))
878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",944 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
879 node->fullpath, unit_addr);945 unit_addr);
880}946}
881WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge);947WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge);
882 948
@@ -892,14 +958,12 @@ static void check_unit_address_format(struct check *c, struct dt_info *dti, · 9 unmodified lines
892 return;958 return;
893 959
894 if (!strncmp(unitname, "0x", 2)) {960 if (!strncmp(unitname, "0x", 2)) {
895 FAIL(c, dti, "Node %s unit name should not have leading \"0x\"",961 FAIL(c, dti, node, "unit name should not have leading \"0x\"");
896 node->fullpath);
897 /* skip over 0x for next test */962 /* skip over 0x for next test */
898 unitname += 2;963 unitname += 2;
899 }964 }
900 if (unitname[0] == '0' && isxdigit(unitname[1]))965 if (unitname[0] == '0' && isxdigit(unitname[1]))
901 FAIL(c, dti, "Node %s unit name should not have leading 0s",966 FAIL(c, dti, node, "unit name should not have leading 0s");
902 node->fullpath);
903}967}
904WARNING(unit_address_format, check_unit_address_format, NULL,968WARNING(unit_address_format, check_unit_address_format, NULL,
905 &node_name_format, &pci_bridge, &simple_bus_bridge);969 &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
922 return;986 return;
923 987
924 if (node->parent->addr_cells == -1)988 if (node->parent->addr_cells == -1)
925 FAIL(c, dti, "Relying on default #address-cells value for %s",989 FAIL(c, dti, node, "Relying on default #address-cells value");
926 node->fullpath);
927 990
928 if (node->parent->size_cells == -1)991 if (node->parent->size_cells == -1)
929 FAIL(c, dti, "Relying on default #size-cells value for %s",992 FAIL(c, dti, node, "Relying on default #size-cells value");
930 node->fullpath);
931}993}
932WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,994WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
933 &addr_size_cells);995 &addr_size_cells);
934 996
997static 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}
1019WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
1020
935static void check_obsolete_chosen_interrupt_controller(struct check *c,1021static void check_obsolete_chosen_interrupt_controller(struct check *c,
936 struct dt_info *dti,1022 struct dt_info *dti,
937 struct node *node)1023 struct node *node)
@@ -950,12 +1036,61 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, · 12 unmodified lines
950 1036
951 prop = get_property(chosen, "interrupt-controller");1037 prop = get_property(chosen, "interrupt-controller");
952 if (prop)1038 if (prop)
953 FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" "1039 FAIL_PROP(c, dti, node, prop,
954 "property");1040 "/chosen has obsolete \"interrupt-controller\" property");
955}1041}
956WARNING(obsolete_chosen_interrupt_controller,1042WARNING(obsolete_chosen_interrupt_controller,
957 check_obsolete_chosen_interrupt_controller, NULL);1043 check_obsolete_chosen_interrupt_controller, NULL);
958 1044
1045static 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}
1054WARNING(chosen_node_is_root, check_chosen_node_is_root, NULL);
1055
1056static 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}
1071WARNING(chosen_node_bootargs, check_chosen_node_bootargs, NULL);
1072
1073static 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}
1092WARNING(chosen_node_stdout_path, check_chosen_node_stdout_path, NULL);
1093
959struct provider {1094struct provider {
960 const char *prop_name;1095 const char *prop_name;
961 const char *cell_name;1096 const char *cell_name;
@@ -972,8 +1107,9 @@ static void check_property_phandle_args(struct check *c, · 10 unmodified lines
972 int cell, cellsize = 0;1107 int cell, cellsize = 0;
973 1108
974 if (prop->val.len % sizeof(cell_t)) {1109 if (prop->val.len % sizeof(cell_t)) {
975 FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",1110 FAIL_PROP(c, dti, node, prop,
976 prop->name, prop->val.len, sizeof(cell_t), node->fullpath);1111 "property size (%d) is invalid, expected multiple of %zu",
1112 prop->val.len, sizeof(cell_t));
977 return;1113 return;
978 }1114 }
979 1115
@@ -1004,14 +1140,16 @@ static void check_property_phandle_args(struct check *c, · 24 unmodified lines
1004 break;1140 break;
1005 }1141 }
1006 if (!m)1142 if (!m)
1007 FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s",1143 FAIL_PROP(c, dti, node, prop,
1008 prop->name, cell, node->fullpath);1144 "cell %d is not a phandle reference",
1145 cell);
1009 }1146 }
1010 1147
1011 provider_node = get_node_by_phandle(root, phandle);1148 provider_node = get_node_by_phandle(root, phandle);
1012 if (!provider_node) {1149 if (!provider_node) {
1013 FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)",1150 FAIL_PROP(c, dti, node, prop,
1014 node->fullpath, prop->name, cell);1151 "Could not get phandle node for (cell %d)",
1152 cell);
1015 break;1153 break;
1016 }1154 }
1017 1155
@@ -1021,16 +1159,17 @@ static void check_property_phandle_args(struct check *c, · 3 unmodified lines
1021 } else if (provider->optional) {1159 } else if (provider->optional) {
1022 cellsize = 0;1160 cellsize = 0;
1023 } else {1161 } 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])",
1025 provider->cell_name,1163 provider->cell_name,
1026 provider_node->fullpath,1164 provider_node->fullpath,
1027 node->fullpath, prop->name, cell);1165 prop->name, cell);
1028 break;1166 break;
1029 }1167 }
1030 1168
1031 if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) {1169 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",1170 FAIL_PROP(c, dti, node, prop,
1033 prop->name, prop->val.len, cellsize, node->fullpath);1171 "property size (%d) too small for cell size %d",
1172 prop->val.len, cellsize);
1034 }1173 }
1035 }1174 }
1036}1175}
@@ -1066,7 +1205,7 @@ WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells"); · 29 unmodified lines
1066WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");1205WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
1067WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");1206WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
1068WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");1207WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
1069WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells");1208WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells");
1070WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");1209WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
1071 1210
1072static bool prop_is_gpio(struct property *prop)1211static bool prop_is_gpio(struct property *prop)
@@ -1132,8 +1271,8 @@ static void check_deprecated_gpio_property(struct check *c, · 59 unmodified lines
1132 if (!streq(str, "gpio"))1271 if (!streq(str, "gpio"))
1133 continue;1272 continue;
1134 1273
1135 FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s",1274 FAIL_PROP(c, dti, node, prop,
1136 node->fullpath, prop->name);1275 "'[*-]gpio' is deprecated, use '[*-]gpios' instead");
1137 }1276 }
1138 1277
1139}1278}
@@ -1167,9 +1306,8 @@ static void check_interrupts_property(struct check *c, · 27 unmodified lines
1167 return;1306 return;
1168 1307
1169 if (irq_prop->val.len % sizeof(cell_t))1308 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",1309 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu",
1171 irq_prop->name, irq_prop->val.len, sizeof(cell_t),1310 irq_prop->val.len, sizeof(cell_t));
1172 node->fullpath);
1173 1311
1174 while (parent && !prop) {1312 while (parent && !prop) {
1175 if (parent != node && node_is_interrupt_provider(parent)) {1313 if (parent != node && node_is_interrupt_provider(parent)) {
@@ -1187,14 +1325,12 @@ static void check_interrupts_property(struct check *c, · 11 unmodified lines
1187 1325
1188 irq_node = get_node_by_phandle(root, phandle);1326 irq_node = get_node_by_phandle(root, phandle);
1189 if (!irq_node) {1327 if (!irq_node) {
1190 FAIL(c, dti, "Bad interrupt-parent phandle for %s",1328 FAIL_PROP(c, dti, parent, prop, "Bad phandle");
1191 node->fullpath);
1192 return;1329 return;
1193 }1330 }
1194 if (!node_is_interrupt_provider(irq_node))1331 if (!node_is_interrupt_provider(irq_node))
1195 FAIL(c, dti,1332 FAIL(c, dti, irq_node,
1196 "Missing interrupt-controller or interrupt-map property in %s",1333 "Missing interrupt-controller or interrupt-map property");
1197 irq_node->fullpath);
1198 1334
1199 break;1335 break;
1200 }1336 }
@@ -1203,23 +1339,21 @@ static void check_interrupts_property(struct check *c, · 2 unmodified lines
1203 }1339 }
1204 1340
1205 if (!irq_node) {1341 if (!irq_node) {
1206 FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath);1342 FAIL(c, dti, node, "Missing interrupt-parent");
1207 return;1343 return;
1208 }1344 }
1209 1345
1210 prop = get_property(irq_node, "#interrupt-cells");1346 prop = get_property(irq_node, "#interrupt-cells");
1211 if (!prop) {1347 if (!prop) {
1212 FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s",1348 FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent");
1213 irq_node->fullpath);
1214 return;1349 return;
1215 }1350 }
1216 1351
1217 irq_cells = propval_cell(prop);1352 irq_cells = propval_cell(prop);
1218 if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {1353 if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
1219 FAIL(c, dti,1354 FAIL_PROP(c, dti, node, prop,
1220 "interrupts size is (%d), expected multiple of %d in %s",1355 "size is (%d), expected multiple of %d",
1221 irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)),1356 irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)));
1222 node->fullpath);
1223 }1357 }
1224}1358}
1225WARNING(interrupts_property, check_interrupts_property, &phandle_references);1359WARNING(interrupts_property, check_interrupts_property, &phandle_references);
@@ -1236,6 +1370,9 @@ static struct check *check_table[] = { · 10 unmodified lines
1236 1370
1237 &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,1371 &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
1238 &device_type_is_string, &model_is_string, &status_is_string,1372 &device_type_is_string, &model_is_string, &status_is_string,
1373 &label_is_string,
1374
1375 &compatible_is_string_list, &names_is_string_list,
1239 1376
1240 &property_name_chars_strict,1377 &property_name_chars_strict,
1241 &node_name_chars_strict,1378 &node_name_chars_strict,
@@ -1253,7 +1390,9 @@ static struct check *check_table[] = { · 11 unmodified lines
1253 &simple_bus_reg,1390 &simple_bus_reg,
1254 1391
1255 &avoid_default_addr_size,1392 &avoid_default_addr_size,
1393 &avoid_unnecessary_addr_size,
1256 &obsolete_chosen_interrupt_controller,1394 &obsolete_chosen_interrupt_controller,
1395 &chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path,
1257 1396
1258 &clocks_property,1397 &clocks_property,
1259 &cooling_device_property,1398 &cooling_device_property,
@@ -1269,13 +1408,15 @@ static struct check *check_table[] = { · 9 unmodified lines
1269 &power_domains_property,1408 &power_domains_property,
1270 &pwms_property,1409 &pwms_property,
1271 &resets_property,1410 &resets_property,
1272 &sound_dais_property,1411 &sound_dai_property,
1273 &thermal_sensors_property,1412 &thermal_sensors_property,
1274 1413
1275 &deprecated_gpio_property,1414 &deprecated_gpio_property,
1276 &gpios_property,1415 &gpios_property,
1277 &interrupts_property,1416 &interrupts_property,
1278 1417
1418 &alias_paths,
1419
1279 &always_fail,1420 &always_fail,
1280};1421};
1281 1422
scripts/dtc/dtc-parser.y+11−6
@@ -166,7 +166,17 @@ devicetree: · 165 unmodified lines
166 {166 {
167 $$ = merge_nodes($1, $3);167 $$ = merge_nodes($1, $3);
168 }168 }
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 }
170 | devicetree DT_LABEL DT_REF nodedef180 | devicetree DT_LABEL DT_REF nodedef
171 {181 {
172 struct node *target = get_node_by_ref($1, $3);182 struct node *target = get_node_by_ref($1, $3);
@@ -209,11 +219,6 @@ devicetree: · 36 unmodified lines
209 219
210 $$ = $1;220 $$ = $1;
211 }221 }
212 | /* empty */
213 {
214 /* build empty node */
215 $$ = name_node(build_node(NULL, NULL), "");
216 }
217 ;222 ;
218 223
219nodedef:224nodedef:
scripts/dtc/dtc.c+3−4
@@ -59,8 +59,6 @@ static void fill_fullpaths(struct node *tree, const char *prefix) · 58 unmodified lines
59}59}
60 60
61/* Usage related data. */61/* Usage related data. */
62#define FDT_VERSION(version) _FDT_VERSION(version)
63#define _FDT_VERSION(version) #version
64static const char usage_synopsis[] = "dtc [options] <input file>";62static const char usage_synopsis[] = "dtc [options] <input file>";
65static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";63static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
66static struct option const usage_long_opts[] = {64static struct option const usage_long_opts[] = {
@@ -98,7 +96,7 @@ static const char * const usage_opts_help[] = { · 31 unmodified lines
98 "\t\tdts - device tree source text\n"96 "\t\tdts - device tree source text\n"
99 "\t\tdtb - device tree blob\n"97 "\t\tdtb - device tree blob\n"
100 "\t\tasm - assembler source",98 "\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)",
102 "\n\tOutput dependency file",100 "\n\tOutput dependency file",
103 "\n\tMake space for <number> reserve map entries (for dtb and asm output)",101 "\n\tMake space for <number> reserve map entries (for dtb and asm output)",
104 "\n\tMake the blob at least <bytes> long (extra space)",102 "\n\tMake the blob at least <bytes> long (extra space)",
@@ -319,13 +317,14 @@ int main(int argc, char *argv[]) · 214 unmodified lines
319 dti->boot_cpuid_phys = cmdline_boot_cpuid;317 dti->boot_cpuid_phys = cmdline_boot_cpuid;
320 318
321 fill_fullpaths(dti->dt, "");319 fill_fullpaths(dti->dt, "");
322 process_checks(force, dti);
323 320
324 /* on a plugin, generate by default */321 /* on a plugin, generate by default */
325 if (dti->dtsflags & DTSF_PLUGIN) {322 if (dti->dtsflags & DTSF_PLUGIN) {
326 generate_fixups = 1;323 generate_fixups = 1;
327 }324 }
328 325
326 process_checks(force, dti);
327
329 if (auto_label_aliases)328 if (auto_label_aliases)
330 generate_label_tree(dti, "aliases", false);329 generate_label_tree(dti, "aliases", false);
331 330
scripts/dtc/dtc.h+6−5
@@ -1,5 +1,5 @@
1#ifndef _DTC_H1#ifndef DTC_H
2#define _DTC_H2#define DTC_H
3 3
4/*4/*
5 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.5 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
@@ -67,7 +67,8 @@ typedef uint32_t cell_t; · 61 unmodified lines
67 67
68 68
69#define streq(a, b) (strcmp((a), (b)) == 0)69#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))
71 72
72#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))73#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
73 74
@@ -203,7 +204,7 @@ struct node *build_node_delete(void); · 129 unmodified lines
203struct node *name_node(struct node *node, char *name);204struct node *name_node(struct node *node, char *name);
204struct node *chain_node(struct node *first, struct node *list);205struct node *chain_node(struct node *first, struct node *list);
205struct node *merge_nodes(struct node *old_node, struct node *new_node);206struct node *merge_nodes(struct node *old_node, struct node *new_node);
206void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);207struct node *add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
207 208
208void add_property(struct node *node, struct property *prop);209void add_property(struct node *node, struct property *prop);
209void delete_property_by_name(struct node *node, char *name);210void 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
289 290
290struct dt_info *dt_from_fs(const char *dirname);291struct dt_info *dt_from_fs(const char *dirname);
291 292
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
731 731
732 plen = strlen(ppath);732 plen = strlen(ppath);
733 733
734 if (!strneq(ppath, cpath, plen))734 if (!strstarts(cpath, ppath))
735 die("Path \"%s\" is not valid as a child of \"%s\"\n",735 die("Path \"%s\" is not valid as a child of \"%s\"\n",
736 cpath, ppath);736 cpath, ppath);
737 737
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
88 || ((offset + len) > fdt_size_dt_struct(fdt)))88 || ((offset + len) > fdt_size_dt_struct(fdt)))
89 return NULL;89 return NULL;
90 90
91 return _fdt_offset_ptr(fdt, offset);91 return fdt_offset_ptr_(fdt, offset);
92}92}
93 93
94uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)94uint32_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
123 /* skip-name offset, length and value */123 /* skip-name offset, length and value */
124 offset += sizeof(struct fdt_property) - FDT_TAGSIZE124 offset += sizeof(struct fdt_property) - FDT_TAGSIZE
125 + fdt32_to_cpu(*lenp);125 + 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;
126 break;129 break;
127 130
128 case FDT_END:131 case FDT_END:
@@ -141,7 +144,7 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) · 12 unmodified lines
141 return tag;144 return tag;
142}145}
143 146
144int _fdt_check_node_offset(const void *fdt, int offset)147int fdt_check_node_offset_(const void *fdt, int offset)
145{148{
146 if ((offset < 0) || (offset % FDT_TAGSIZE)149 if ((offset < 0) || (offset % FDT_TAGSIZE)
147 || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))150 || (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
150 return offset;153 return offset;
151}154}
152 155
153int _fdt_check_prop_offset(const void *fdt, int offset)156int fdt_check_prop_offset_(const void *fdt, int offset)
154{157{
155 if ((offset < 0) || (offset % FDT_TAGSIZE)158 if ((offset < 0) || (offset % FDT_TAGSIZE)
156 || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))159 || (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
165 uint32_t tag;168 uint32_t tag;
166 169
167 if (offset >= 0)170 if (offset >= 0)
168 if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)171 if ((nextoffset = fdt_check_node_offset_(fdt, offset)) < 0)
169 return nextoffset;172 return nextoffset;
170 173
171 do {174 do {
@@ -227,7 +230,7 @@ int fdt_next_subnode(const void *fdt, int offset) · 55 unmodified lines
227 return offset;230 return offset;
228}231}
229 232
230const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)233const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
231{234{
232 int len = strlen(s) + 1;235 int len = strlen(s) + 1;
233 const char *last = strtab + tabsize - len;236 const char *last = strtab + tabsize - len;
scripts/dtc/libfdt/fdt.h+3−3
@@ -1,5 +1,5 @@
1#ifndef _FDT_H1#ifndef FDT_H
2#define _FDT_H2#define FDT_H
3/*3/*
4 * libfdt - Flat Device Tree manipulation4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.5 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -108,4 +108,4 @@ struct fdt_property { · 102 unmodified lines
108#define FDT_V16_SIZE FDT_V3_SIZE108#define FDT_V16_SIZE FDT_V3_SIZE
109#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))109#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
110 110
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 */
1#include "libfdt_env.h"52#include "libfdt_env.h"
2 53
3#include <fdt.h>54#include <fdt.h>
scripts/dtc/libfdt/fdt_ro.c+101−31
@@ -55,12 +55,13 @@ · 54 unmodified lines
55 55
56#include "libfdt_internal.h"56#include "libfdt_internal.h"
57 57
58static int _fdt_nodename_eq(const void *fdt, int offset,58static int fdt_nodename_eq_(const void *fdt, int offset,
59 const char *s, int len)59 const char *s, int len)
60{60{
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);
62 63
63 if (!p)64 if (!p || olen < len)
64 /* short match */65 /* short match */
65 return 0;66 return 0;
66 67
@@ -80,7 +81,7 @@ const char *fdt_string(const void *fdt, int stroffset) · 13 unmodified lines
80 return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;81 return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
81}82}
82 83
83static int _fdt_string_eq(const void *fdt, int stroffset,84static int fdt_string_eq_(const void *fdt, int stroffset,
84 const char *s, int len)85 const char *s, int len)
85{86{
86 const char *p = fdt_string(fdt, stroffset);87 const char *p = fdt_string(fdt, stroffset);
@@ -117,8 +118,8 @@ uint32_t fdt_get_max_phandle(const void *fdt) · 30 unmodified lines
117int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)118int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
118{119{
119 FDT_CHECK_HEADER(fdt);120 FDT_CHECK_HEADER(fdt);
120 *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);121 *address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address);
121 *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);122 *size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size);
122 return 0;123 return 0;
123}124}
124 125
@@ -126,12 +127,12 @@ int fdt_num_mem_rsv(const void *fdt) · 1 unmodified line
126{127{
127 int i = 0;128 int i = 0;
128 129
129 while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)130 while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0)
130 i++;131 i++;
131 return i;132 return i;
132}133}
133 134
134static int _nextprop(const void *fdt, int offset)135static int nextprop_(const void *fdt, int offset)
135{136{
136 uint32_t tag;137 uint32_t tag;
137 int nextoffset;138 int nextoffset;
@@ -166,7 +167,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset, · 28 unmodified lines
166 (offset >= 0) && (depth >= 0);167 (offset >= 0) && (depth >= 0);
167 offset = fdt_next_node(fdt, offset, &depth))168 offset = fdt_next_node(fdt, offset, &depth))
168 if ((depth == 1)169 if ((depth == 1)
169 && _fdt_nodename_eq(fdt, offset, name, namelen))170 && fdt_nodename_eq_(fdt, offset, name, namelen))
170 return offset;171 return offset;
171 172
172 if (depth < 0)173 if (depth < 0)
@@ -232,17 +233,35 @@ int fdt_path_offset(const void *fdt, const char *path) · 59 unmodified lines
232 233
233const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)234const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
234{235{
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;
236 int err;238 int err;
237 239
238 if (((err = fdt_check_header(fdt)) != 0)240 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))
240 goto fail;242 goto fail;
241 243
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
242 if (len)261 if (len)
243 *len = strlen(nh->name);262 *len = strlen(nameptr);
244 263
245 return nh->name;264 return nameptr;
246 265
247 fail:266 fail:
248 if (len)267 if (len)
@@ -254,34 +273,34 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset) · 5 unmodified lines
254{273{
255 int offset;274 int offset;
256 275
257 if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)276 if ((offset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
258 return offset;277 return offset;
259 278
260 return _nextprop(fdt, offset);279 return nextprop_(fdt, offset);
261}280}
262 281
263int fdt_next_property_offset(const void *fdt, int offset)282int fdt_next_property_offset(const void *fdt, int offset)
264{283{
265 if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0)284 if ((offset = fdt_check_prop_offset_(fdt, offset)) < 0)
266 return offset;285 return offset;
267 286
268 return _nextprop(fdt, offset);287 return nextprop_(fdt, offset);
269}288}
270 289
271const struct fdt_property *fdt_get_property_by_offset(const void *fdt,290static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt,
272 int offset,291 int offset,
273 int *lenp)292 int *lenp)
274{293{
275 int err;294 int err;
276 const struct fdt_property *prop;295 const struct fdt_property *prop;
277 296
278 if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) {297 if ((err = fdt_check_prop_offset_(fdt, offset)) < 0) {
279 if (lenp)298 if (lenp)
280 *lenp = err;299 *lenp = err;
281 return NULL;300 return NULL;
282 }301 }
283 302
284 prop = _fdt_offset_ptr(fdt, offset);303 prop = fdt_offset_ptr_(fdt, offset);
285 304
286 if (lenp)305 if (lenp)
287 *lenp = fdt32_to_cpu(prop->len);306 *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
289 return prop;308 return prop;
290}309}
291 310
292const struct fdt_property *fdt_get_property_namelen(const void *fdt,311const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
293 int offset,312 int offset,
294 const char *name,313 int *lenp)
295 int namelen, 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
327static 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)
296{333{
297 for (offset = fdt_first_property_offset(fdt, offset);334 for (offset = fdt_first_property_offset(fdt, offset);
298 (offset >= 0);335 (offset >= 0);
299 (offset = fdt_next_property_offset(fdt, offset))) {336 (offset = fdt_next_property_offset(fdt, offset))) {
300 const struct fdt_property *prop;337 const struct fdt_property *prop;
301 338
302 if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) {339 if (!(prop = fdt_get_property_by_offset_(fdt, offset, lenp))) {
303 offset = -FDT_ERR_INTERNAL;340 offset = -FDT_ERR_INTERNAL;
304 break;341 break;
305 }342 }
306 if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff),343 if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff),
307 name, namelen))344 name, namelen)) {
345 if (poffset)
346 *poffset = offset;
308 return prop;347 return prop;
348 }
309 }349 }
310 350
311 if (lenp)351 if (lenp)
@@ -313,6 +353,25 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt, · 1 unmodified line
313 return NULL;353 return NULL;
314}354}
315 355
356
357const 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
316const struct fdt_property *fdt_get_property(const void *fdt,375const struct fdt_property *fdt_get_property(const void *fdt,
317 int nodeoffset,376 int nodeoffset,
318 const char *name, int *lenp)377 const char *name, int *lenp)
@@ -324,12 +383,18 @@ const struct fdt_property *fdt_get_property(const void *fdt, · 5 unmodified lines
324const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,383const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
325 const char *name, int namelen, int *lenp)384 const char *name, int namelen, int *lenp)
326{385{
386 int poffset;
327 const struct fdt_property *prop;387 const struct fdt_property *prop;
328 388
329 prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);389 prop = fdt_get_property_namelen_(fdt, nodeoffset, name, namelen, lenp,
390 &poffset);
330 if (!prop)391 if (!prop)
331 return NULL;392 return NULL;
332 393
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;
333 return prop->data;398 return prop->data;
334}399}
335 400
@@ -338,11 +403,16 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, · 2 unmodified lines
338{403{
339 const struct fdt_property *prop;404 const struct fdt_property *prop;
340 405
341 prop = fdt_get_property_by_offset(fdt, offset, lenp);406 prop = fdt_get_property_by_offset_(fdt, offset, lenp);
342 if (!prop)407 if (!prop)
343 return NULL;408 return NULL;
344 if (namep)409 if (namep)
345 *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));410 *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;
346 return prop->data;416 return prop->data;
347}417}
348 418
scripts/dtc/libfdt/fdt_rw.c+45−45
@@ -55,8 +55,8 @@ · 54 unmodified lines
55 55
56#include "libfdt_internal.h"56#include "libfdt_internal.h"
57 57
58static int _fdt_blocks_misordered(const void *fdt,58static int fdt_blocks_misordered_(const void *fdt,
59 int mem_rsv_size, int struct_size)59 int mem_rsv_size, int struct_size)
60{60{
61 return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))61 return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
62 || (fdt_off_dt_struct(fdt) <62 || (fdt_off_dt_struct(fdt) <
@@ -67,13 +67,13 @@ static int _fdt_blocks_misordered(const void *fdt, · 4 unmodified lines
67 (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));67 (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
68}68}
69 69
70static int _fdt_rw_check_header(void *fdt)70static int fdt_rw_check_header_(void *fdt)
71{71{
72 FDT_CHECK_HEADER(fdt);72 FDT_CHECK_HEADER(fdt);
73 73
74 if (fdt_version(fdt) < 17)74 if (fdt_version(fdt) < 17)
75 return -FDT_ERR_BADVERSION;75 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),
77 fdt_size_dt_struct(fdt)))77 fdt_size_dt_struct(fdt)))
78 return -FDT_ERR_BADLAYOUT;78 return -FDT_ERR_BADLAYOUT;
79 if (fdt_version(fdt) > 17)79 if (fdt_version(fdt) > 17)
@@ -84,20 +84,20 @@ static int _fdt_rw_check_header(void *fdt) · 4 unmodified lines
84 84
85#define FDT_RW_CHECK_HEADER(fdt) \85#define FDT_RW_CHECK_HEADER(fdt) \
86 { \86 { \
87 int __err; \87 int err_; \
88 if ((__err = _fdt_rw_check_header(fdt)) != 0) \88 if ((err_ = fdt_rw_check_header_(fdt)) != 0) \
89 return __err; \89 return err_; \
90 }90 }
91 91
92static inline int _fdt_data_size(void *fdt)92static inline int fdt_data_size_(void *fdt)
93{93{
94 return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);94 return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
95}95}
96 96
97static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)97static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen)
98{98{
99 char *p = splicepoint;99 char *p = splicepoint;
100 char *end = (char *)fdt + _fdt_data_size(fdt);100 char *end = (char *)fdt + fdt_data_size_(fdt);
101 101
102 if (((p + oldlen) < p) || ((p + oldlen) > end))102 if (((p + oldlen) < p) || ((p + oldlen) > end))
103 return -FDT_ERR_BADOFFSET;103 return -FDT_ERR_BADOFFSET;
@@ -109,12 +109,12 @@ static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen) · 5 unmodified lines
109 return 0;109 return 0;
110}110}
111 111
112static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,112static int fdt_splice_mem_rsv_(void *fdt, struct fdt_reserve_entry *p,
113 int oldn, int newn)113 int oldn, int newn)
114{114{
115 int delta = (newn - oldn) * sizeof(*p);115 int delta = (newn - oldn) * sizeof(*p);
116 int err;116 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));
118 if (err)118 if (err)
119 return err;119 return err;
120 fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);120 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
122 return 0;122 return 0;
123}123}
124 124
125static int _fdt_splice_struct(void *fdt, void *p,125static int fdt_splice_struct_(void *fdt, void *p,
126 int oldlen, int newlen)126 int oldlen, int newlen)
127{127{
128 int delta = newlen - oldlen;128 int delta = newlen - oldlen;
129 int err;129 int err;
130 130
131 if ((err = _fdt_splice(fdt, p, oldlen, newlen)))131 if ((err = fdt_splice_(fdt, p, oldlen, newlen)))
132 return err;132 return err;
133 133
134 fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);134 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
136 return 0;136 return 0;
137}137}
138 138
139static int _fdt_splice_string(void *fdt, int newlen)139static int fdt_splice_string_(void *fdt, int newlen)
140{140{
141 void *p = (char *)fdt141 void *p = (char *)fdt
142 + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);142 + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
143 int err;143 int err;
144 144
145 if ((err = _fdt_splice(fdt, p, 0, newlen)))145 if ((err = fdt_splice_(fdt, p, 0, newlen)))
146 return err;146 return err;
147 147
148 fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);148 fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
149 return 0;149 return 0;
150}150}
151 151
152static int _fdt_find_add_string(void *fdt, const char *s)152static int fdt_find_add_string_(void *fdt, const char *s)
153{153{
154 char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);154 char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
155 const char *p;155 const char *p;
@@ -157,13 +157,13 @@ static int _fdt_find_add_string(void *fdt, const char *s) · 1 unmodified line
157 int len = strlen(s) + 1;157 int len = strlen(s) + 1;
158 int err;158 int err;
159 159
160 p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);160 p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
161 if (p)161 if (p)
162 /* found it */162 /* found it */
163 return (p - strtab);163 return (p - strtab);
164 164
165 new = strtab + fdt_size_dt_strings(fdt);165 new = strtab + fdt_size_dt_strings(fdt);
166 err = _fdt_splice_string(fdt, len);166 err = fdt_splice_string_(fdt, len);
167 if (err)167 if (err)
168 return err;168 return err;
169 169
@@ -178,8 +178,8 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) · 8 unmodified lines
178 178
179 FDT_RW_CHECK_HEADER(fdt);179 FDT_RW_CHECK_HEADER(fdt);
180 180
181 re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));181 re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt));
182 err = _fdt_splice_mem_rsv(fdt, re, 0, 1);182 err = fdt_splice_mem_rsv_(fdt, re, 0, 1);
183 if (err)183 if (err)
184 return err;184 return err;
185 185
@@ -190,17 +190,17 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) · 4 unmodified lines
190 190
191int fdt_del_mem_rsv(void *fdt, int n)191int fdt_del_mem_rsv(void *fdt, int n)
192{192{
193 struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);193 struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n);
194 194
195 FDT_RW_CHECK_HEADER(fdt);195 FDT_RW_CHECK_HEADER(fdt);
196 196
197 if (n >= fdt_num_mem_rsv(fdt))197 if (n >= fdt_num_mem_rsv(fdt))
198 return -FDT_ERR_NOTFOUND;198 return -FDT_ERR_NOTFOUND;
199 199
200 return _fdt_splice_mem_rsv(fdt, re, 1, 0);200 return fdt_splice_mem_rsv_(fdt, re, 1, 0);
201}201}
202 202
203static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,203static int fdt_resize_property_(void *fdt, int nodeoffset, const char *name,
204 int len, struct fdt_property **prop)204 int len, struct fdt_property **prop)
205{205{
206 int oldlen;206 int oldlen;
@@ -210,7 +210,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, · 3 unmodified lines
210 if (!*prop)210 if (!*prop)
211 return oldlen;211 return oldlen;
212 212
213 if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),213 if ((err = fdt_splice_struct_(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
214 FDT_TAGALIGN(len))))214 FDT_TAGALIGN(len))))
215 return err;215 return err;
216 216
@@ -218,7 +218,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
218 return 0;218 return 0;
219}219}
220 220
221static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,221static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
222 int len, struct fdt_property **prop)222 int len, struct fdt_property **prop)
223{223{
224 int proplen;224 int proplen;
@@ -226,17 +226,17 @@ static int _fdt_add_property(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
226 int namestroff;226 int namestroff;
227 int err;227 int err;
228 228
229 if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)229 if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
230 return nextoffset;230 return nextoffset;
231 231
232 namestroff = _fdt_find_add_string(fdt, name);232 namestroff = fdt_find_add_string_(fdt, name);
233 if (namestroff < 0)233 if (namestroff < 0)
234 return namestroff;234 return namestroff;
235 235
236 *prop = _fdt_offset_ptr_w(fdt, nextoffset);236 *prop = fdt_offset_ptr_w_(fdt, nextoffset);
237 proplen = sizeof(**prop) + FDT_TAGALIGN(len);237 proplen = sizeof(**prop) + FDT_TAGALIGN(len);
238 238
239 err = _fdt_splice_struct(fdt, *prop, 0, proplen);239 err = fdt_splice_struct_(fdt, *prop, 0, proplen);
240 if (err)240 if (err)
241 return err;241 return err;
242 242
@@ -260,7 +260,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name) · 17 unmodified lines
260 260
261 newlen = strlen(name);261 newlen = strlen(name);
262 262
263 err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),263 err = fdt_splice_struct_(fdt, namep, FDT_TAGALIGN(oldlen+1),
264 FDT_TAGALIGN(newlen+1));264 FDT_TAGALIGN(newlen+1));
265 if (err)265 if (err)
266 return err;266 return err;
@@ -277,9 +277,9 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, · 10 unmodified lines
277 277
278 FDT_RW_CHECK_HEADER(fdt);278 FDT_RW_CHECK_HEADER(fdt);
279 279
280 err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);280 err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop);
281 if (err == -FDT_ERR_NOTFOUND)281 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);
283 if (err)283 if (err)
284 return err;284 return err;
285 285
@@ -313,7 +313,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, · 27 unmodified lines
313 prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);313 prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
314 if (prop) {314 if (prop) {
315 newlen = len + oldlen;315 newlen = len + oldlen;
316 err = _fdt_splice_struct(fdt, prop->data,316 err = fdt_splice_struct_(fdt, prop->data,
317 FDT_TAGALIGN(oldlen),317 FDT_TAGALIGN(oldlen),
318 FDT_TAGALIGN(newlen));318 FDT_TAGALIGN(newlen));
319 if (err)319 if (err)
@@ -321,7 +321,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, · 1 unmodified line
321 prop->len = cpu_to_fdt32(newlen);321 prop->len = cpu_to_fdt32(newlen);
322 memcpy(prop->data + oldlen, val, len);322 memcpy(prop->data + oldlen, val, len);
323 } else {323 } else {
324 err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);324 err = fdt_add_property_(fdt, nodeoffset, name, len, &prop);
325 if (err)325 if (err)
326 return err;326 return err;
327 memcpy(prop->data, val, len);327 memcpy(prop->data, val, len);
@@ -341,7 +341,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name) · 13 unmodified lines
341 return len;341 return len;
342 342
343 proplen = sizeof(*prop) + FDT_TAGALIGN(len);343 proplen = sizeof(*prop) + FDT_TAGALIGN(len);
344 return _fdt_splice_struct(fdt, prop, proplen, 0);344 return fdt_splice_struct_(fdt, prop, proplen, 0);
345}345}
346 346
347int fdt_add_subnode_namelen(void *fdt, int parentoffset,347int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@@ -369,10 +369,10 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, · 21 unmodified lines
369 tag = fdt_next_tag(fdt, offset, &nextoffset);369 tag = fdt_next_tag(fdt, offset, &nextoffset);
370 } while ((tag == FDT_PROP) || (tag == FDT_NOP));370 } while ((tag == FDT_PROP) || (tag == FDT_NOP));
371 371
372 nh = _fdt_offset_ptr_w(fdt, offset);372 nh = fdt_offset_ptr_w_(fdt, offset);
373 nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;373 nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
374 374
375 err = _fdt_splice_struct(fdt, nh, 0, nodelen);375 err = fdt_splice_struct_(fdt, nh, 0, nodelen);
376 if (err)376 if (err)
377 return err;377 return err;
378 378
@@ -396,15 +396,15 @@ int fdt_del_node(void *fdt, int nodeoffset) · 17 unmodified lines
396 396
397 FDT_RW_CHECK_HEADER(fdt);397 FDT_RW_CHECK_HEADER(fdt);
398 398
399 endoffset = _fdt_node_end_offset(fdt, nodeoffset);399 endoffset = fdt_node_end_offset_(fdt, nodeoffset);
400 if (endoffset < 0)400 if (endoffset < 0)
401 return endoffset;401 return endoffset;
402 402
403 return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),403 return fdt_splice_struct_(fdt, fdt_offset_ptr_w_(fdt, nodeoffset),
404 endoffset - nodeoffset, 0);404 endoffset - nodeoffset, 0);
405}405}
406 406
407static void _fdt_packblocks(const char *old, char *new,407static void fdt_packblocks_(const char *old, char *new,
408 int mem_rsv_size, int struct_size)408 int mem_rsv_size, int struct_size)
409{409{
410 int mem_rsv_off, struct_off, strings_off;410 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
450 return struct_size;450 return struct_size;
451 }451 }
452 452
453 if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {453 if (!fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) {
454 /* no further work necessary */454 /* no further work necessary */
455 err = fdt_move(fdt, buf, bufsize);455 err = fdt_move(fdt, buf, bufsize);
456 if (err)456 if (err)
@@ -478,7 +478,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) · 21 unmodified lines
478 return -FDT_ERR_NOSPACE;478 return -FDT_ERR_NOSPACE;
479 }479 }
480 480
481 _fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);481 fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size);
482 memmove(buf, tmp, newsize);482 memmove(buf, tmp, newsize);
483 483
484 fdt_set_magic(buf, FDT_MAGIC);484 fdt_set_magic(buf, FDT_MAGIC);
@@ -498,8 +498,8 @@ int fdt_pack(void *fdt) · 13 unmodified lines
498 498
499 mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)499 mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
500 * sizeof(struct fdt_reserve_entry);500 * sizeof(struct fdt_reserve_entry);
501 _fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));501 fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
502 fdt_set_totalsize(fdt, _fdt_data_size(fdt));502 fdt_set_totalsize(fdt, fdt_data_size_(fdt));
503 503
504 return 0;504 return 0;
505}505}
scripts/dtc/libfdt/fdt_sw.c+12−12
@@ -55,7 +55,7 @@ · 54 unmodified lines
55 55
56#include "libfdt_internal.h"56#include "libfdt_internal.h"
57 57
58static int _fdt_sw_check_header(void *fdt)58static int fdt_sw_check_header_(void *fdt)
59{59{
60 if (fdt_magic(fdt) != FDT_SW_MAGIC)60 if (fdt_magic(fdt) != FDT_SW_MAGIC)
61 return -FDT_ERR_BADMAGIC;61 return -FDT_ERR_BADMAGIC;
@@ -66,11 +66,11 @@ static int _fdt_sw_check_header(void *fdt) · 4 unmodified lines
66#define FDT_SW_CHECK_HEADER(fdt) \66#define FDT_SW_CHECK_HEADER(fdt) \
67 { \67 { \
68 int err; \68 int err; \
69 if ((err = _fdt_sw_check_header(fdt)) != 0) \69 if ((err = fdt_sw_check_header_(fdt)) != 0) \
70 return err; \70 return err; \
71 }71 }
72 72
73static void *_fdt_grab_space(void *fdt, size_t len)73static void *fdt_grab_space_(void *fdt, size_t len)
74{74{
75 int offset = fdt_size_dt_struct(fdt);75 int offset = fdt_size_dt_struct(fdt);
76 int spaceleft;76 int spaceleft;
@@ -82,7 +82,7 @@ static void *_fdt_grab_space(void *fdt, size_t len) · 5 unmodified lines
82 return NULL;82 return NULL;
83 83
84 fdt_set_size_dt_struct(fdt, offset + len);84 fdt_set_size_dt_struct(fdt, offset + len);
85 return _fdt_offset_ptr_w(fdt, offset);85 return fdt_offset_ptr_w_(fdt, offset);
86}86}
87 87
88int fdt_create(void *buf, int bufsize)88int fdt_create(void *buf, int bufsize)
@@ -174,7 +174,7 @@ int fdt_begin_node(void *fdt, const char *name) · 85 unmodified lines
174 174
175 FDT_SW_CHECK_HEADER(fdt);175 FDT_SW_CHECK_HEADER(fdt);
176 176
177 nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));177 nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
178 if (! nh)178 if (! nh)
179 return -FDT_ERR_NOSPACE;179 return -FDT_ERR_NOSPACE;
180 180
@@ -189,7 +189,7 @@ int fdt_end_node(void *fdt) · 8 unmodified lines
189 189
190 FDT_SW_CHECK_HEADER(fdt);190 FDT_SW_CHECK_HEADER(fdt);
191 191
192 en = _fdt_grab_space(fdt, FDT_TAGSIZE);192 en = fdt_grab_space_(fdt, FDT_TAGSIZE);
193 if (! en)193 if (! en)
194 return -FDT_ERR_NOSPACE;194 return -FDT_ERR_NOSPACE;
195 195
@@ -197,7 +197,7 @@ int fdt_end_node(void *fdt) · 1 unmodified line
197 return 0;197 return 0;
198}198}
199 199
200static int _fdt_find_add_string(void *fdt, const char *s)200static int fdt_find_add_string_(void *fdt, const char *s)
201{201{
202 char *strtab = (char *)fdt + fdt_totalsize(fdt);202 char *strtab = (char *)fdt + fdt_totalsize(fdt);
203 const char *p;203 const char *p;
@@ -205,7 +205,7 @@ static int _fdt_find_add_string(void *fdt, const char *s) · 1 unmodified line
205 int len = strlen(s) + 1;205 int len = strlen(s) + 1;
206 int struct_top, offset;206 int struct_top, offset;
207 207
208 p = _fdt_find_string(strtab - strtabsize, strtabsize, s);208 p = fdt_find_string_(strtab - strtabsize, strtabsize, s);
209 if (p)209 if (p)
210 return p - strtab;210 return p - strtab;
211 211
@@ -227,11 +227,11 @@ int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) · 15 unmodified lines
227 227
228 FDT_SW_CHECK_HEADER(fdt);228 FDT_SW_CHECK_HEADER(fdt);
229 229
230 nameoff = _fdt_find_add_string(fdt, name);230 nameoff = fdt_find_add_string_(fdt, name);
231 if (nameoff == 0)231 if (nameoff == 0)
232 return -FDT_ERR_NOSPACE;232 return -FDT_ERR_NOSPACE;
233 233
234 prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));234 prop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
235 if (! prop)235 if (! prop)
236 return -FDT_ERR_NOSPACE;236 return -FDT_ERR_NOSPACE;
237 237
@@ -265,7 +265,7 @@ int fdt_finish(void *fdt) · 27 unmodified lines
265 FDT_SW_CHECK_HEADER(fdt);265 FDT_SW_CHECK_HEADER(fdt);
266 266
267 /* Add terminator */267 /* Add terminator */
268 end = _fdt_grab_space(fdt, sizeof(*end));268 end = fdt_grab_space_(fdt, sizeof(*end));
269 if (! end)269 if (! end)
270 return -FDT_ERR_NOSPACE;270 return -FDT_ERR_NOSPACE;
271 *end = cpu_to_fdt32(FDT_END);271 *end = cpu_to_fdt32(FDT_END);
@@ -281,7 +281,7 @@ int fdt_finish(void *fdt) · 9 unmodified lines
281 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {281 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
282 if (tag == FDT_PROP) {282 if (tag == FDT_PROP) {
283 struct fdt_property *prop =283 struct fdt_property *prop =
284 _fdt_offset_ptr_w(fdt, offset);284 fdt_offset_ptr_w_(fdt, offset);
285 int nameoff;285 int nameoff;
286 286
287 nameoff = fdt32_to_cpu(prop->nameoff);287 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
93 val, len);93 val, len);
94}94}
95 95
96static void _fdt_nop_region(void *start, int len)96static void fdt_nop_region_(void *start, int len)
97{97{
98 fdt32_t *p;98 fdt32_t *p;
99 99
@@ -110,12 +110,12 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name) · 10 unmodified lines
110 if (!prop)110 if (!prop)
111 return len;111 return len;
112 112
113 _fdt_nop_region(prop, len + sizeof(*prop));113 fdt_nop_region_(prop, len + sizeof(*prop));
114 114
115 return 0;115 return 0;
116}116}
117 117
118int _fdt_node_end_offset(void *fdt, int offset)118int fdt_node_end_offset_(void *fdt, int offset)
119{119{
120 int depth = 0;120 int depth = 0;
121 121
@@ -129,11 +129,11 @@ int fdt_nop_node(void *fdt, int nodeoffset) · 7 unmodified lines
129{129{
130 int endoffset;130 int endoffset;
131 131
132 endoffset = _fdt_node_end_offset(fdt, nodeoffset);132 endoffset = fdt_node_end_offset_(fdt, nodeoffset);
133 if (endoffset < 0)133 if (endoffset < 0)
134 return endoffset;134 return endoffset;
135 135
136 _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),136 fdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0),
137 endoffset - nodeoffset);137 endoffset - nodeoffset);
138 return 0;138 return 0;
139}139}
scripts/dtc/libfdt/libfdt.h+20−17
@@ -1,5 +1,5 @@
1#ifndef _LIBFDT_H1#ifndef LIBFDT_H
2#define _LIBFDT_H2#define LIBFDT_H
3/*3/*
4 * libfdt - Flat Device Tree manipulation4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.5 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -54,7 +54,7 @@ · 48 unmodified lines
54#include "libfdt_env.h"54#include "libfdt_env.h"
55#include "fdt.h"55#include "fdt.h"
56 56
57#define FDT_FIRST_SUPPORTED_VERSION 0x1057#define FDT_FIRST_SUPPORTED_VERSION 0x02
58#define FDT_LAST_SUPPORTED_VERSION 0x1158#define FDT_LAST_SUPPORTED_VERSION 0x11
59 59
60/* Error codes: informative error codes */60/* Error codes: informative error codes */
@@ -225,23 +225,23 @@ int fdt_next_subnode(const void *fdt, int offset); · 164 unmodified lines
225#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))225#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
226#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))226#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
227 227
228#define __fdt_set_hdr(name) \228#define fdt_set_hdr_(name) \
229 static inline void fdt_set_##name(void *fdt, uint32_t val) \229 static inline void fdt_set_##name(void *fdt, uint32_t val) \
230 { \230 { \
231 struct fdt_header *fdth = (struct fdt_header *)fdt; \231 struct fdt_header *fdth = (struct fdt_header *)fdt; \
232 fdth->name = cpu_to_fdt32(val); \232 fdth->name = cpu_to_fdt32(val); \
233 }233 }
234__fdt_set_hdr(magic);234fdt_set_hdr_(magic);
235__fdt_set_hdr(totalsize);235fdt_set_hdr_(totalsize);
236__fdt_set_hdr(off_dt_struct);236fdt_set_hdr_(off_dt_struct);
237__fdt_set_hdr(off_dt_strings);237fdt_set_hdr_(off_dt_strings);
238__fdt_set_hdr(off_mem_rsvmap);238fdt_set_hdr_(off_mem_rsvmap);
239__fdt_set_hdr(version);239fdt_set_hdr_(version);
240__fdt_set_hdr(last_comp_version);240fdt_set_hdr_(last_comp_version);
241__fdt_set_hdr(boot_cpuid_phys);241fdt_set_hdr_(boot_cpuid_phys);
242__fdt_set_hdr(size_dt_strings);242fdt_set_hdr_(size_dt_strings);
243__fdt_set_hdr(size_dt_struct);243fdt_set_hdr_(size_dt_struct);
244#undef __fdt_set_hdr244#undef fdt_set_hdr_
245 245
246/**246/**
247 * fdt_check_header - sanity check a device tree or possible device tree247 * 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
527 * offset. If lenp is non-NULL, the length of the property value is527 * offset. If lenp is non-NULL, the length of the property value is
528 * also returned, in the integer pointed to by lenp.528 * also returned, in the integer pointed to by lenp.
529 *529 *
530 * Note that this code only works on device tree versions >= 16. fdt_getprop()
531 * works on all versions.
532 *
530 * returns:533 * returns:
531 * pointer to the structure representing the property534 * pointer to the structure representing the property
532 * if lenp is non-NULL, *lenp contains the length of the property535 * 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
1449 const void *val, int len);1452 const void *val, int len);
1450 1453
1451/**1454/**
1452 * fdt_setprop _placeholder - allocate space for a property1455 * fdt_setprop_placeholder - allocate space for a property
1453 * @fdt: pointer to the device tree blob1456 * @fdt: pointer to the device tree blob
1454 * @nodeoffset: offset of the node whose property to change1457 * @nodeoffset: offset of the node whose property to change
1455 * @name: name of the property to change1458 * @name: name of the property to change
@@ -1896,4 +1899,4 @@ int fdt_overlay_apply(void *fdt, void *fdto); · 440 unmodified lines
1896 1899
1897const char *fdt_strerror(int errval);1900const char *fdt_strerror(int errval);
1898 1901
1899#endif /* _LIBFDT_H */1902#endif /* LIBFDT_H */
scripts/dtc/libfdt/libfdt_env.h+30−3
@@ -1,5 +1,5 @@
1#ifndef _LIBFDT_ENV_H1#ifndef LIBFDT_ENV_H
2#define _LIBFDT_ENV_H2#define LIBFDT_ENV_H
3/*3/*
4 * libfdt - Flat Device Tree manipulation4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.5 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -109,4 +109,31 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x) · 103 unmodified lines
109#undef CPU_TO_FDT16109#undef CPU_TO_FDT16
110#undef EXTRACT_BYTE110#undef EXTRACT_BYTE
111 111
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 */
128static 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_H1#ifndef LIBFDT_INTERNAL_H
2#define _LIBFDT_INTERNAL_H2#define LIBFDT_INTERNAL_H
3/*3/*
4 * libfdt - Flat Device Tree manipulation4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.5 * Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -57,27 +57,27 @@ · 51 unmodified lines
57 57
58#define FDT_CHECK_HEADER(fdt) \58#define FDT_CHECK_HEADER(fdt) \
59 { \59 { \
60 int __err; \60 int err_; \
61 if ((__err = fdt_check_header(fdt)) != 0) \61 if ((err_ = fdt_check_header(fdt)) != 0) \
62 return __err; \62 return err_; \
63 }63 }
64 64
65int _fdt_check_node_offset(const void *fdt, int offset);65int fdt_check_node_offset_(const void *fdt, int offset);
66int _fdt_check_prop_offset(const void *fdt, int offset);66int fdt_check_prop_offset_(const void *fdt, int offset);
67const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);67const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
68int _fdt_node_end_offset(void *fdt, int nodeoffset);68int fdt_node_end_offset_(void *fdt, int nodeoffset);
69 69
70static inline const void *_fdt_offset_ptr(const void *fdt, int offset)70static inline const void *fdt_offset_ptr_(const void *fdt, int offset)
71{71{
72 return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;72 return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
73}73}
74 74
75static inline void *_fdt_offset_ptr_w(void *fdt, int offset)75static inline void *fdt_offset_ptr_w_(void *fdt, int offset)
76{76{
77 return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);77 return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset);
78}78}
79 79
80static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)80static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n)
81{81{
82 const struct fdt_reserve_entry *rsv_table =82 const struct fdt_reserve_entry *rsv_table =
83 (const struct fdt_reserve_entry *)83 (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
85 85
86 return rsv_table + n;86 return rsv_table + n;
87}87}
88static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)88static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
89{89{
90 return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);90 return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
91}91}
92 92
93#define FDT_SW_MAGIC (~FDT_MAGIC)93#define FDT_SW_MAGIC (~FDT_MAGIC)
94 94
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
216 return old_node;216 return old_node;
217}217}
218 218
219void add_orphan_node(struct node *dt, struct node *new_node, char *ref)219struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
220{220{
221 static unsigned int next_orphan_fragment = 0;221 static unsigned int next_orphan_fragment = 0;
222 struct node *node;222 struct node *node;
@@ -236,6 +236,7 @@ void add_orphan_node(struct node *dt, struct node *new_node, char *ref) · 13 unmodified lines
236 name_node(node, name);236 name_node(node, name);
237 237
238 add_child(dt, node);238 add_child(dt, node);
239 return dt;
239}240}
240 241
241struct node *chain_node(struct node *first, struct node *list)242struct 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
507 508
508 for_each_child(tree, child) {509 for_each_child(tree, child) {
509 if (p && (strlen(child->name) == p-path) &&510 if (p && (strlen(child->name) == p-path) &&
510 strneq(path, child->name, p-path))511 strprefixeq(path, p - path, child->name))
511 return get_node_by_path(child, p+1);512 return get_node_by_path(child, p+1);
512 else if (!p && streq(path, child->name))513 else if (!p && streq(path, child->name))
513 return child;514 return child;
@@ -540,7 +541,10 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle) · 26 unmodified lines
540{541{
541 struct node *child, *node;542 struct node *child, *node;
542 543
543 assert((phandle != 0) && (phandle != -1));544 if ((phandle == 0) || (phandle == -1)) {
545 assert(generate_fixups);
546 return NULL;
547 }
544 548
545 if (tree->phandle == phandle) {549 if (tree->phandle == phandle) {
546 if (tree->deleted)550 if (tree->deleted)
scripts/dtc/srcpos.c+0−5
@@ -209,8 +209,6 @@ struct srcpos srcpos_empty = { · 208 unmodified lines
209 .file = NULL,209 .file = NULL,
210};210};
211 211
212#define TAB_SIZE 8
213
214void srcpos_update(struct srcpos *pos, const char *text, int len)212void srcpos_update(struct srcpos *pos, const char *text, int len)
215{213{
216 int i;214 int i;
@@ -224,9 +222,6 @@ void srcpos_update(struct srcpos *pos, const char *text, int len) · 7 unmodified lines
224 if (text[i] == '\n') {222 if (text[i] == '\n') {
225 current_srcfile->lineno++;223 current_srcfile->lineno++;
226 current_srcfile->colno = 1;224 current_srcfile->colno = 1;
227 } else if (text[i] == '\t') {
228 current_srcfile->colno =
229 ALIGN(current_srcfile->colno, TAB_SIZE);
230 } else {225 } else {
231 current_srcfile->colno++;226 current_srcfile->colno++;
232 }227 }
scripts/dtc/srcpos.h+3−3
@@ -17,8 +17,8 @@ · 16 unmodified lines
17 * USA17 * USA
18 */18 */
19 19
20#ifndef _SRCPOS_H_20#ifndef SRCPOS_H
21#define _SRCPOS_H_21#define SRCPOS_H
22 22
23#include <stdio.h>23#include <stdio.h>
24#include <stdbool.h>24#include <stdbool.h>
@@ -114,4 +114,4 @@ extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix, · 89 unmodified lines
114 114
115extern void srcpos_set_line(char *f, int l);115extern void srcpos_set_line(char *f, int l);
116 116
117#endif /* _SRCPOS_H_ */117#endif /* SRCPOS_H */
scripts/dtc/util.h+6−3
@@ -1,5 +1,5 @@
1#ifndef _UTIL_H1#ifndef UTIL_H
2#define _UTIL_H2#define UTIL_H
3 3
4#include <stdarg.h>4#include <stdarg.h>
5#include <stdbool.h>5#include <stdbool.h>
@@ -35,6 +35,9 @@ · 29 unmodified lines
35 35
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37 37
38#define stringify(s) stringify_(s)
39#define stringify_(s) #s
40
38static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)41static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
39{42{
40 va_list ap;43 va_list ap;
@@ -260,4 +263,4 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis, · 219 unmodified lines
260 case 'V': util_version(); \263 case 'V': util_version(); \
261 case '?': usage("unknown option");264 case '?': usage("unknown option");
262 265
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"