Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property

12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * You should have received a copy of the GNU General Public License
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 fprintf(stderr, "=== %s: ", (c)->name); \
49 typedef void (*tree_check_fn)(struct check *c, struct node *dt);
50 typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
51 typedef void (*prop_check_fn)(struct check *c, struct node *dt,
52 struct node *node, struct property *prop);
98 if ((c->level < WARN) || (c->level <= quiet)) in check_msg()
102 (c->level == ERROR) ? "ERROR" : "Warning", c->name); in check_msg()
110 (c)->status = FAILED; \
114 static void check_nodes_props(struct check *c, struct node *dt, struct node *node) in check_nodes_props() argument
116 struct node *child; in check_nodes_props() local
117 struct property *prop; in check_nodes_props()
119 TRACE(c, "%s", node->fullpath); in check_nodes_props()
120 if (c->node_fn) in check_nodes_props()
121 c->node_fn(c, dt, node); in check_nodes_props()
123 if (c->prop_fn) in check_nodes_props()
124 for_each_property(node, prop) { in check_nodes_props()
125 TRACE(c, "%s\t'%s'", node->fullpath, prop->name); in check_nodes_props()
126 c->prop_fn(c, dt, node, prop); in check_nodes_props()
129 for_each_child(node, child) in check_nodes_props()
130 check_nodes_props(c, dt, child); in check_nodes_props()
133 static int run_check(struct check *c, struct node *dt) in run_check()
138 assert(!c->inprogress); in run_check()
140 if (c->status != UNCHECKED) in run_check()
143 c->inprogress = 1; in run_check()
145 for (i = 0; i < c->num_prereqs; i++) { in run_check()
146 struct check *prq = c->prereq[i]; in run_check()
148 if (prq->status != PASSED) { in run_check()
149 c->status = PREREQ; in run_check()
151 c->prereq[i]->name); in run_check()
155 if (c->status != UNCHECKED) in run_check()
158 if (c->node_fn || c->prop_fn) in run_check()
161 if (c->tree_fn) in run_check()
162 c->tree_fn(c, dt); in run_check()
163 if (c->status == UNCHECKED) in run_check()
164 c->status = PASSED; in run_check()
166 TRACE(c, "\tCompleted, status %d", c->status); in run_check()
169 c->inprogress = 0; in run_check()
170 if ((c->status != PASSED) && (c->level == ERROR)) in run_check()
179 static void check_is_string(struct check *c, struct node *root, in check_is_string()
180 struct node *node) in check_is_string() argument
182 struct property *prop; in check_is_string()
183 char *propname = c->data; in check_is_string()
185 prop = get_property(node, propname); in check_is_string()
189 if (!data_is_one_string(prop->val)) in check_is_string()
190 FAIL(c, "\"%s\" property in %s is not a string", in check_is_string()
191 propname, node->fullpath); in check_is_string()
196 static void check_is_cell(struct check *c, struct node *root, in check_is_cell()
197 struct node *node) in check_is_cell() argument
199 struct property *prop; in check_is_cell()
200 char *propname = c->data; in check_is_cell()
202 prop = get_property(node, propname); in check_is_cell()
206 if (prop->val.len != sizeof(cell_t)) in check_is_cell()
207 FAIL(c, "\"%s\" property in %s is not a single cell", in check_is_cell()
208 propname, node->fullpath); in check_is_cell()
217 static void check_duplicate_node_names(struct check *c, struct node *dt, in check_duplicate_node_names()
218 struct node *node) in check_duplicate_node_names() argument
220 struct node *child, *child2; in check_duplicate_node_names() local
222 for_each_child(node, child) in check_duplicate_node_names()
223 for (child2 = child->next_sibling; in check_duplicate_node_names()
225 child2 = child2->next_sibling) in check_duplicate_node_names()
226 if (streq(child->name, child2->name)) in check_duplicate_node_names()
227 FAIL(c, "Duplicate node name %s", in check_duplicate_node_names()
228 child->fullpath); in check_duplicate_node_names()
232 static void check_duplicate_property_names(struct check *c, struct node *dt, in check_duplicate_property_names()
233 struct node *node) in check_duplicate_property_names() argument
235 struct property *prop, *prop2; in check_duplicate_property_names()
237 for_each_property(node, prop) in check_duplicate_property_names()
238 for (prop2 = prop->next; prop2; prop2 = prop2->next) in check_duplicate_property_names()
239 if (streq(prop->name, prop2->name)) in check_duplicate_property_names()
240 FAIL(c, "Duplicate property name %s in %s", in check_duplicate_property_names()
241 prop->name, node->fullpath); in check_duplicate_property_names()
248 #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
250 static void check_node_name_chars(struct check *c, struct node *dt, in check_node_name_chars()
251 struct node *node) in check_node_name_chars() argument
253 int n = strspn(node->name, c->data); in check_node_name_chars()
255 if (n < strlen(node->name)) in check_node_name_chars()
256 FAIL(c, "Bad character '%c' in node %s", in check_node_name_chars()
257 node->name[n], node->fullpath); in check_node_name_chars()
261 static void check_node_name_format(struct check *c, struct node *dt, in check_node_name_format()
262 struct node *node) in check_node_name_format() argument
264 if (strchr(get_unitname(node), '@')) in check_node_name_format()
265 FAIL(c, "Node %s has multiple '@' characters in name", in check_node_name_format()
266 node->fullpath); in check_node_name_format()
270 static void check_property_name_chars(struct check *c, struct node *dt, in check_property_name_chars()
271 struct node *node, struct property *prop) in check_property_name_chars() argument
273 int n = strspn(prop->name, c->data); in check_property_name_chars()
275 if (n < strlen(prop->name)) in check_property_name_chars()
276 FAIL(c, "Bad character '%c' in property name \"%s\", node %s", in check_property_name_chars()
277 prop->name[n], prop->name, node->fullpath); in check_property_name_chars()
282 #define DESCLABEL_ARGS(node,prop,mark) \ argument
285 ((prop) ? (prop)->name : ""), \
286 ((prop) ? "' in " : ""), (node)->fullpath
288 static void check_duplicate_label(struct check *c, struct node *dt, in check_duplicate_label()
289 const char *label, struct node *node, in check_duplicate_label() argument
290 struct property *prop, struct marker *mark) in check_duplicate_label()
292 struct node *othernode = NULL; in check_duplicate_label()
293 struct property *otherprop = NULL; in check_duplicate_label()
307 if ((othernode != node) || (otherprop != prop) || (othermark != mark)) in check_duplicate_label()
310 label, DESCLABEL_ARGS(node, prop, mark), in check_duplicate_label()
314 static void check_duplicate_label_node(struct check *c, struct node *dt, in check_duplicate_label_node()
315 struct node *node) in check_duplicate_label_node() argument
319 for_each_label(node->labels, l) in check_duplicate_label_node()
320 check_duplicate_label(c, dt, l->label, node, NULL, NULL); in check_duplicate_label_node()
322 static void check_duplicate_label_prop(struct check *c, struct node *dt, in check_duplicate_label_prop()
323 struct node *node, struct property *prop) in check_duplicate_label_prop() argument
325 struct marker *m = prop->val.markers; in check_duplicate_label_prop()
328 for_each_label(prop->labels, l) in check_duplicate_label_prop()
329 check_duplicate_label(c, dt, l->label, node, prop, NULL); in check_duplicate_label_prop()
332 check_duplicate_label(c, dt, m->ref, node, prop, m); in check_duplicate_label_prop()
337 static void check_explicit_phandles(struct check *c, struct node *root, in check_explicit_phandles()
338 struct node *node, struct property *prop) in check_explicit_phandles() argument
341 struct node *other; in check_explicit_phandles()
344 if (!streq(prop->name, "phandle") in check_explicit_phandles()
345 && !streq(prop->name, "linux,phandle")) in check_explicit_phandles()
348 if (prop->val.len != sizeof(cell_t)) { in check_explicit_phandles()
349 FAIL(c, "%s has bad length (%d) %s property", in check_explicit_phandles()
350 node->fullpath, prop->val.len, prop->name); in check_explicit_phandles()
354 m = prop->val.markers; in check_explicit_phandles()
356 assert(m->offset == 0); in check_explicit_phandles()
357 if (node != get_node_by_ref(root, m->ref)) in check_explicit_phandles()
358 /* "Set this node's phandle equal to some in check_explicit_phandles()
359 * other node's phandle". That's nonsensical in check_explicit_phandles()
361 FAIL(c, "%s in %s is a reference to another node", in check_explicit_phandles()
362 prop->name, node->fullpath); in check_explicit_phandles()
365 /* But setting this node's phandle equal to its own in check_explicit_phandles()
366 * phandle is allowed - that means allocate a unique in check_explicit_phandles()
367 * phandle for this node, even if it's not otherwise in check_explicit_phandles()
375 if ((phandle == 0) || (phandle == -1)) { in check_explicit_phandles()
376 FAIL(c, "%s has bad value (0x%x) in %s property", in check_explicit_phandles()
377 node->fullpath, phandle, prop->name); in check_explicit_phandles()
381 if (node->phandle && (node->phandle != phandle)) in check_explicit_phandles()
382 FAIL(c, "%s has %s property which replaces existing phandle information", in check_explicit_phandles()
383 node->fullpath, prop->name); in check_explicit_phandles()
386 if (other && (other != node)) { in check_explicit_phandles()
388 node->fullpath, phandle, other->fullpath); in check_explicit_phandles()
392 node->phandle = phandle; in check_explicit_phandles()
396 static void check_name_properties(struct check *c, struct node *root, in check_name_properties()
397 struct node *node) in check_name_properties() argument
399 struct property **pp, *prop = NULL; in check_name_properties()
401 for (pp = &node->proplist; *pp; pp = &((*pp)->next)) in check_name_properties()
402 if (streq((*pp)->name, "name")) { in check_name_properties()
408 return; /* No name property, that's fine */ in check_name_properties()
410 if ((prop->val.len != node->basenamelen+1) in check_name_properties()
411 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { in check_name_properties()
412 FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead" in check_name_properties()
413 " of base node name)", node->fullpath, prop->val.val); in check_name_properties()
415 /* The name property is correct, and therefore redundant. in check_name_properties()
417 *pp = prop->next; in check_name_properties()
418 free(prop->name); in check_name_properties()
419 data_free(prop->val); in check_name_properties()
430 static void fixup_phandle_references(struct check *c, struct node *dt, in fixup_phandle_references()
431 struct node *node, struct property *prop) in fixup_phandle_references() argument
433 struct marker *m = prop->val.markers; in fixup_phandle_references()
434 struct node *refnode; in fixup_phandle_references()
438 assert(m->offset + sizeof(cell_t) <= prop->val.len); in fixup_phandle_references()
440 refnode = get_node_by_ref(dt, m->ref); in fixup_phandle_references()
442 FAIL(c, "Reference to non-existent node or label \"%s\"\n", in fixup_phandle_references()
443 m->ref); in fixup_phandle_references()
448 *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); in fixup_phandle_references()
454 static void fixup_path_references(struct check *c, struct node *dt, in fixup_path_references()
455 struct node *node, struct property *prop) in fixup_path_references() argument
457 struct marker *m = prop->val.markers; in fixup_path_references()
458 struct node *refnode; in fixup_path_references()
462 assert(m->offset <= prop->val.len); in fixup_path_references()
464 refnode = get_node_by_ref(dt, m->ref); in fixup_path_references()
466 FAIL(c, "Reference to non-existent node or label \"%s\"\n", in fixup_path_references()
467 m->ref); in fixup_path_references()
471 path = refnode->fullpath; in fixup_path_references()
472 prop->val = data_insert_at_marker(prop->val, m, path, in fixup_path_references()
482 CHECK_IS_CELL(address_cells_is_cell, "#address-cells", WARN);
483 CHECK_IS_CELL(size_cells_is_cell, "#size-cells", WARN);
484 CHECK_IS_CELL(interrupt_cells_is_cell, "#interrupt-cells", WARN);
490 static void fixup_addr_size_cells(struct check *c, struct node *dt, in fixup_addr_size_cells()
491 struct node *node) in fixup_addr_size_cells() argument
493 struct property *prop; in fixup_addr_size_cells()
495 node->addr_cells = -1; in fixup_addr_size_cells()
496 node->size_cells = -1; in fixup_addr_size_cells()
498 prop = get_property(node, "#address-cells"); in fixup_addr_size_cells()
500 node->addr_cells = propval_cell(prop); in fixup_addr_size_cells()
502 prop = get_property(node, "#size-cells"); in fixup_addr_size_cells()
504 node->size_cells = propval_cell(prop); in fixup_addr_size_cells()
510 (((n)->addr_cells == -1) ? 2 : (n)->addr_cells)
512 (((n)->size_cells == -1) ? 1 : (n)->size_cells)
514 static void check_reg_format(struct check *c, struct node *dt, in check_reg_format()
515 struct node *node) in check_reg_format() argument
517 struct property *prop; in check_reg_format()
520 prop = get_property(node, "reg"); in check_reg_format()
524 if (!node->parent) { in check_reg_format()
525 FAIL(c, "Root node has a \"reg\" property"); in check_reg_format()
529 if (prop->val.len == 0) in check_reg_format()
530 FAIL(c, "\"reg\" property in %s is empty", node->fullpath); in check_reg_format()
532 addr_cells = node_addr_cells(node->parent); in check_reg_format()
533 size_cells = node_size_cells(node->parent); in check_reg_format()
536 if ((prop->val.len % entrylen) != 0) in check_reg_format()
537 FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) " in check_reg_format()
538 "(#address-cells == %d, #size-cells == %d)", in check_reg_format()
539 node->fullpath, prop->val.len, addr_cells, size_cells); in check_reg_format()
543 static void check_ranges_format(struct check *c, struct node *dt, in check_ranges_format()
544 struct node *node) in check_ranges_format() argument
546 struct property *prop; in check_ranges_format()
549 prop = get_property(node, "ranges"); in check_ranges_format()
553 if (!node->parent) { in check_ranges_format()
554 FAIL(c, "Root node has a \"ranges\" property"); in check_ranges_format()
558 p_addr_cells = node_addr_cells(node->parent); in check_ranges_format()
559 p_size_cells = node_size_cells(node->parent); in check_ranges_format()
560 c_addr_cells = node_addr_cells(node); in check_ranges_format()
561 c_size_cells = node_size_cells(node); in check_ranges_format()
564 if (prop->val.len == 0) { in check_ranges_format()
566 FAIL(c, "%s has empty \"ranges\" property but its " in check_ranges_format()
567 "#address-cells (%d) differs from %s (%d)", in check_ranges_format()
568 node->fullpath, c_addr_cells, node->parent->fullpath, in check_ranges_format()
571 FAIL(c, "%s has empty \"ranges\" property but its " in check_ranges_format()
572 "#size-cells (%d) differs from %s (%d)", in check_ranges_format()
573 node->fullpath, c_size_cells, node->parent->fullpath, in check_ranges_format()
575 } else if ((prop->val.len % entrylen) != 0) { in check_ranges_format()
576 FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) " in check_ranges_format()
577 "(parent #address-cells == %d, child #address-cells == %d, " in check_ranges_format()
578 "#size-cells == %d)", node->fullpath, prop->val.len, in check_ranges_format()
587 static void check_avoid_default_addr_size(struct check *c, struct node *dt, in check_avoid_default_addr_size()
588 struct node *node) in check_avoid_default_addr_size() argument
590 struct property *reg, *ranges; in check_avoid_default_addr_size()
592 if (!node->parent) in check_avoid_default_addr_size()
593 return; /* Ignore root node */ in check_avoid_default_addr_size()
595 reg = get_property(node, "reg"); in check_avoid_default_addr_size()
596 ranges = get_property(node, "ranges"); in check_avoid_default_addr_size()
601 if ((node->parent->addr_cells == -1)) in check_avoid_default_addr_size()
602 FAIL(c, "Relying on default #address-cells value for %s", in check_avoid_default_addr_size()
603 node->fullpath); in check_avoid_default_addr_size()
605 if ((node->parent->size_cells == -1)) in check_avoid_default_addr_size()
606 FAIL(c, "Relying on default #size-cells value for %s", in check_avoid_default_addr_size()
607 node->fullpath); in check_avoid_default_addr_size()
612 struct node *dt) in check_obsolete_chosen_interrupt_controller()
614 struct node *chosen; in check_obsolete_chosen_interrupt_controller()
615 struct property *prop; in check_obsolete_chosen_interrupt_controller()
621 prop = get_property(chosen, "interrupt-controller"); in check_obsolete_chosen_interrupt_controller()
623 FAIL(c, "/chosen has obsolete \"interrupt-controller\" " in check_obsolete_chosen_interrupt_controller()
624 "property"); in check_obsolete_chosen_interrupt_controller()
649 struct node *dt = bi->dt; in process_checks()
656 if (c->level != IGNORE) in process_checks()
663 "(use -f to force output)\n"); in process_checks()