summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/checks.c
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2018-02-27 18:40:38 -0500
committerRob Herring <robh@kernel.org>2018-03-05 21:58:17 -0500
commit9130ba884640328bb78aaa4840e5ddf06ccafb1c (patch)
tree078f18589cd0b7c09f4d918f75d67644b15d2e22 /scripts/dtc/checks.c
parente039139be8c25145b103ab365ff1bd4a540066a3 (diff)
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. Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'scripts/dtc/checks.c')
-rw-r--r--scripts/dtc/checks.c439
1 files changed, 290 insertions, 149 deletions
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index e66138449886..c07ba4da9e36 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -53,26 +53,28 @@ struct check {
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,
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)
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:
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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_FMT 411 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,
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,
422 /* "Set this node's phandle equal to some 460 /* "Set this node's phandle equal to some
423 * other node's phandle". That's nonsensical 461 * 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 own 466 /* But setting this node's phandle equal to its own
429 * phandle is allowed - that means allocate a unique 467 * 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,
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,
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,
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,
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,
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");
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,
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,
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,
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 *
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
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
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
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)
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
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
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,
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,
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,
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,
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,
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,
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");
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,
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,
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,
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,
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[] = {
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[] = {
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[] = {
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