Lines Matching refs:node
43 typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node);
76 struct node *node, in check_msg() argument
88 if (node) { in check_msg()
89 fprintf(stderr, "%s", node->fullpath); in check_msg()
100 #define FAIL(c, dti, node, ...) \ argument
104 check_msg((c), dti, node, NULL, __VA_ARGS__); \
107 #define FAIL_PROP(c, dti, node, prop, ...) \ argument
111 check_msg((c), dti, node, prop, __VA_ARGS__); \
114 static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) in check_nodes_props() argument
116 struct node *child; in check_nodes_props()
118 TRACE(c, "%s", node->fullpath); in check_nodes_props()
120 c->fn(c, dti, node); in check_nodes_props()
122 for_each_child(node, child) in check_nodes_props()
128 struct node *dt = dti->dt; in run_check()
172 struct node *node) in check_always_fail() argument
174 FAIL(c, dti, node, "always_fail check"); in check_always_fail()
179 struct node *node) in check_is_string() argument
184 prop = get_property(node, propname); in check_is_string()
189 FAIL_PROP(c, dti, node, prop, "property is not a string"); in check_is_string()
197 struct node *node) in check_is_string_list() argument
204 prop = get_property(node, propname); in check_is_string_list()
213 FAIL_PROP(c, dti, node, prop, "property is not a string list"); in check_is_string_list()
226 struct node *node) in check_is_cell() argument
231 prop = get_property(node, propname); in check_is_cell()
236 FAIL_PROP(c, dti, node, prop, "property is not a single cell"); in check_is_cell()
248 struct node *node) in check_duplicate_node_names() argument
250 struct node *child, *child2; in check_duplicate_node_names()
252 for_each_child(node, child) in check_duplicate_node_names()
262 struct node *node) in check_duplicate_property_names() argument
266 for_each_property(node, prop) { in check_duplicate_property_names()
271 FAIL_PROP(c, dti, node, prop, "Duplicate property name"); in check_duplicate_property_names()
284 struct node *node) in check_node_name_chars() argument
286 int n = strspn(node->name, c->data); in check_node_name_chars()
288 if (n < strlen(node->name)) in check_node_name_chars()
289 FAIL(c, dti, node, "Bad character '%c' in node name", in check_node_name_chars()
290 node->name[n]); in check_node_name_chars()
295 struct node *node) in check_node_name_chars_strict() argument
297 int n = strspn(node->name, c->data); in check_node_name_chars_strict()
299 if (n < node->basenamelen) in check_node_name_chars_strict()
300 FAIL(c, dti, node, "Character '%c' not recommended in node name", in check_node_name_chars_strict()
301 node->name[n]); in check_node_name_chars_strict()
306 struct node *node) in check_node_name_format() argument
308 if (strchr(get_unitname(node), '@')) in check_node_name_format()
309 FAIL(c, dti, node, "multiple '@' characters in node name"); in check_node_name_format()
314 struct node *node) in check_unit_address_vs_reg() argument
316 const char *unitname = get_unitname(node); in check_unit_address_vs_reg()
317 struct property *prop = get_property(node, "reg"); in check_unit_address_vs_reg()
319 if (get_subnode(node, "__overlay__")) { in check_unit_address_vs_reg()
325 prop = get_property(node, "ranges"); in check_unit_address_vs_reg()
332 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name"); in check_unit_address_vs_reg()
335 FAIL(c, dti, node, "node has a unit name, but no reg property"); in check_unit_address_vs_reg()
341 struct node *node) in check_property_name_chars() argument
345 for_each_property(node, prop) { in check_property_name_chars()
349 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name", in check_property_name_chars()
357 struct node *node) in check_property_name_chars_strict() argument
361 for_each_property(node, prop) { in check_property_name_chars_strict()
381 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name", in check_property_name_chars_strict()
388 #define DESCLABEL_ARGS(node,prop,mark) \ argument
392 ((prop) ? "' in " : ""), (node)->fullpath
395 const char *label, struct node *node, in check_duplicate_label() argument
398 struct node *dt = dti->dt; in check_duplicate_label()
399 struct node *othernode = NULL; in check_duplicate_label()
414 if ((othernode != node) || (otherprop != prop) || (othermark != mark)) in check_duplicate_label()
415 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT in check_duplicate_label()
417 label, DESCLABEL_ARGS(node, prop, mark), in check_duplicate_label()
422 struct node *node) in check_duplicate_label_node() argument
427 for_each_label(node->labels, l) in check_duplicate_label_node()
428 check_duplicate_label(c, dti, l->label, node, NULL, NULL); in check_duplicate_label_node()
430 for_each_property(node, prop) { in check_duplicate_label_node()
434 check_duplicate_label(c, dti, l->label, node, prop, NULL); in check_duplicate_label_node()
437 check_duplicate_label(c, dti, m->ref, node, prop, m); in check_duplicate_label_node()
443 struct node *node, const char *propname) in check_phandle_prop() argument
445 struct node *root = dti->dt; in check_phandle_prop()
450 prop = get_property(node, propname); in check_phandle_prop()
455 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property", in check_phandle_prop()
463 if (node != get_node_by_ref(root, m->ref)) in check_phandle_prop()
467 FAIL(c, dti, node, "%s is a reference to another node", in check_phandle_prop()
481 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property", in check_phandle_prop()
490 struct node *node) in check_explicit_phandles() argument
492 struct node *root = dti->dt; in check_explicit_phandles()
493 struct node *other; in check_explicit_phandles()
497 assert(!node->phandle); in check_explicit_phandles()
499 phandle = check_phandle_prop(c, dti, node, "phandle"); in check_explicit_phandles()
501 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle"); in check_explicit_phandles()
508 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'" in check_explicit_phandles()
515 if (other && (other != node)) { in check_explicit_phandles()
516 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)", in check_explicit_phandles()
521 node->phandle = phandle; in check_explicit_phandles()
526 struct node *node) in check_name_properties() argument
530 for (pp = &node->proplist; *pp; pp = &((*pp)->next)) in check_name_properties()
539 if ((prop->val.len != node->basenamelen+1) in check_name_properties()
540 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { in check_name_properties()
541 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead" in check_name_properties()
560 struct node *node) in fixup_phandle_references() argument
562 struct node *dt = dti->dt; in fixup_phandle_references()
565 for_each_property(node, prop) { in fixup_phandle_references()
567 struct node *refnode; in fixup_phandle_references()
576 FAIL(c, dti, node, "Reference to non-existent node or " in fixup_phandle_references()
595 struct node *node) in fixup_path_references() argument
597 struct node *dt = dti->dt; in fixup_path_references()
600 for_each_property(node, prop) { in fixup_path_references()
602 struct node *refnode; in fixup_path_references()
610 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n", in fixup_path_references()
626 struct node *node) in fixup_omit_unused_nodes() argument
628 if (node->omit_if_unused && !node->is_referenced) in fixup_omit_unused_nodes()
629 delete_node(node); in fixup_omit_unused_nodes()
648 struct node *node) in check_names_is_string_list() argument
652 for_each_property(node, prop) { in check_names_is_string_list()
658 check_is_string_list(c, dti, node); in check_names_is_string_list()
664 struct node *node) in check_alias_paths() argument
668 if (!streq(node->name, "aliases")) in check_alias_paths()
671 for_each_property(node, prop) { in check_alias_paths()
673 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)", in check_alias_paths()
678 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'"); in check_alias_paths()
684 struct node *node) in fixup_addr_size_cells() argument
688 node->addr_cells = -1; in fixup_addr_size_cells()
689 node->size_cells = -1; in fixup_addr_size_cells()
691 prop = get_property(node, "#address-cells"); in fixup_addr_size_cells()
693 node->addr_cells = propval_cell(prop); in fixup_addr_size_cells()
695 prop = get_property(node, "#size-cells"); in fixup_addr_size_cells()
697 node->size_cells = propval_cell(prop); in fixup_addr_size_cells()
708 struct node *node) in check_reg_format() argument
713 prop = get_property(node, "reg"); in check_reg_format()
717 if (!node->parent) { in check_reg_format()
718 FAIL(c, dti, node, "Root node has a \"reg\" property"); in check_reg_format()
723 FAIL_PROP(c, dti, node, prop, "property is empty"); in check_reg_format()
725 addr_cells = node_addr_cells(node->parent); in check_reg_format()
726 size_cells = node_size_cells(node->parent); in check_reg_format()
730 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) " in check_reg_format()
737 struct node *node) in check_ranges_format() argument
742 prop = get_property(node, "ranges"); in check_ranges_format()
746 if (!node->parent) { in check_ranges_format()
747 FAIL_PROP(c, dti, node, prop, "Root node has a \"ranges\" property"); in check_ranges_format()
751 p_addr_cells = node_addr_cells(node->parent); in check_ranges_format()
752 p_size_cells = node_size_cells(node->parent); in check_ranges_format()
753 c_addr_cells = node_addr_cells(node); in check_ranges_format()
754 c_size_cells = node_size_cells(node); in check_ranges_format()
759 FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its " in check_ranges_format()
761 c_addr_cells, node->parent->fullpath, in check_ranges_format()
764 FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its " in check_ranges_format()
766 c_size_cells, node->parent->fullpath, in check_ranges_format()
769 FAIL_PROP(c, dti, node, prop, "\"ranges\" property has invalid length (%d bytes) " in check_ranges_format()
781 static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_pci_bridge() argument
786 prop = get_property(node, "device_type"); in check_pci_bridge()
790 node->bus = &pci_bus; in check_pci_bridge()
792 if (!strprefixeq(node->name, node->basenamelen, "pci") && in check_pci_bridge()
793 !strprefixeq(node->name, node->basenamelen, "pcie")) in check_pci_bridge()
794 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\""); in check_pci_bridge()
796 prop = get_property(node, "ranges"); in check_pci_bridge()
798 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)"); in check_pci_bridge()
800 if (node_addr_cells(node) != 3) in check_pci_bridge()
801 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge"); in check_pci_bridge()
802 if (node_size_cells(node) != 2) in check_pci_bridge()
803 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge"); in check_pci_bridge()
805 prop = get_property(node, "bus-range"); in check_pci_bridge()
807 FAIL(c, dti, node, "missing bus-range for PCI bridge"); in check_pci_bridge()
811 FAIL_PROP(c, dti, node, prop, "value must be 2 cells"); in check_pci_bridge()
816 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell"); in check_pci_bridge()
818 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256"); in check_pci_bridge()
823 static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node) in check_pci_device_bus_num() argument
829 if (!node->parent || (node->parent->bus != &pci_bus)) in check_pci_device_bus_num()
832 prop = get_property(node, "reg"); in check_pci_device_bus_num()
839 prop = get_property(node->parent, "bus-range"); in check_pci_device_bus_num()
848 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)", in check_pci_device_bus_num()
853 static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node) in check_pci_device_reg() argument
856 const char *unitname = get_unitname(node); in check_pci_device_reg()
861 if (!node->parent || (node->parent->bus != &pci_bus)) in check_pci_device_reg()
864 prop = get_property(node, "reg"); in check_pci_device_reg()
866 FAIL(c, dti, node, "missing PCI reg property"); in check_pci_device_reg()
872 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0"); in check_pci_device_reg()
879 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space"); in check_pci_device_reg()
881 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0"); in check_pci_device_reg()
893 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"", in check_pci_device_reg()
902 static bool node_is_compatible(struct node *node, const char *compat) in node_is_compatible() argument
907 prop = get_property(node, "compatible"); in node_is_compatible()
919 static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_simple_bus_bridge() argument
921 if (node_is_compatible(node, "simple-bus")) in check_simple_bus_bridge()
922 node->bus = &simple_bus; in check_simple_bus_bridge()
926 static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node) in check_simple_bus_reg() argument
929 const char *unitname = get_unitname(node); in check_simple_bus_reg()
935 if (!node->parent || (node->parent->bus != &simple_bus)) in check_simple_bus_reg()
938 prop = get_property(node, "reg"); in check_simple_bus_reg()
942 prop = get_property(node, "ranges"); in check_simple_bus_reg()
945 cells = ((cell_t *)prop->val.val) + node_addr_cells(node); in check_simple_bus_reg()
949 if (node->parent->parent && !(node->bus == &simple_bus)) in check_simple_bus_reg()
950 FAIL(c, dti, node, "missing or empty reg/ranges property"); in check_simple_bus_reg()
954 size = node_addr_cells(node->parent); in check_simple_bus_reg()
960 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"", in check_simple_bus_reg()
966 struct node *node) in check_unit_address_format() argument
968 const char *unitname = get_unitname(node); in check_unit_address_format()
970 if (node->parent && node->parent->bus) in check_unit_address_format()
977 FAIL(c, dti, node, "unit name should not have leading \"0x\""); in check_unit_address_format()
982 FAIL(c, dti, node, "unit name should not have leading 0s"); in check_unit_address_format()
991 struct node *node) in check_avoid_default_addr_size() argument
995 if (!node->parent) in check_avoid_default_addr_size()
998 reg = get_property(node, "reg"); in check_avoid_default_addr_size()
999 ranges = get_property(node, "ranges"); in check_avoid_default_addr_size()
1004 if (node->parent->addr_cells == -1) in check_avoid_default_addr_size()
1005 FAIL(c, dti, node, "Relying on default #address-cells value"); in check_avoid_default_addr_size()
1007 if (node->parent->size_cells == -1) in check_avoid_default_addr_size()
1008 FAIL(c, dti, node, "Relying on default #size-cells value"); in check_avoid_default_addr_size()
1014 struct node *node) in check_avoid_unnecessary_addr_size() argument
1017 struct node *child; in check_avoid_unnecessary_addr_size()
1020 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0) in check_avoid_unnecessary_addr_size()
1023 if (get_property(node, "ranges") || !node->children) in check_avoid_unnecessary_addr_size()
1026 for_each_child(node, child) { in check_avoid_unnecessary_addr_size()
1033 …FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" pro… in check_avoid_unnecessary_addr_size()
1038 struct node *node) in check_unique_unit_address() argument
1040 struct node *childa; in check_unique_unit_address()
1042 if (node->addr_cells < 0 || node->size_cells < 0) in check_unique_unit_address()
1045 if (!node->children) in check_unique_unit_address()
1048 for_each_child(node, childa) { in check_unique_unit_address()
1049 struct node *childb; in check_unique_unit_address()
1055 for_each_child(node, childb) { in check_unique_unit_address()
1069 struct node *node) in check_obsolete_chosen_interrupt_controller() argument
1071 struct node *dt = dti->dt; in check_obsolete_chosen_interrupt_controller()
1072 struct node *chosen; in check_obsolete_chosen_interrupt_controller()
1075 if (node != dt) in check_obsolete_chosen_interrupt_controller()
1084 FAIL_PROP(c, dti, node, prop, in check_obsolete_chosen_interrupt_controller()
1091 struct node *node) in check_chosen_node_is_root() argument
1093 if (!streq(node->name, "chosen")) in check_chosen_node_is_root()
1096 if (node->parent != dti->dt) in check_chosen_node_is_root()
1097 FAIL(c, dti, node, "chosen node must be at root node"); in check_chosen_node_is_root()
1102 struct node *node) in check_chosen_node_bootargs() argument
1106 if (!streq(node->name, "chosen")) in check_chosen_node_bootargs()
1109 prop = get_property(node, "bootargs"); in check_chosen_node_bootargs()
1114 check_is_string(c, dti, node); in check_chosen_node_bootargs()
1119 struct node *node) in check_chosen_node_stdout_path() argument
1123 if (!streq(node->name, "chosen")) in check_chosen_node_stdout_path()
1126 prop = get_property(node, "stdout-path"); in check_chosen_node_stdout_path()
1128 prop = get_property(node, "linux,stdout-path"); in check_chosen_node_stdout_path()
1131 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead"); in check_chosen_node_stdout_path()
1135 check_is_string(c, dti, node); in check_chosen_node_stdout_path()
1147 struct node *node, in check_property_phandle_args() argument
1151 struct node *root = dti->dt; in check_property_phandle_args()
1155 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1162 struct node *provider_node; in check_property_phandle_args()
1188 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1195 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1207 FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])", in check_property_phandle_args()
1215 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1224 struct node *node) in check_provider_cells_property() argument
1229 prop = get_property(node, provider->prop_name); in check_provider_cells_property()
1233 check_property_phandle_args(c, dti, node, prop, provider); in check_provider_cells_property()
1280 struct node *node) in check_gpios_property() argument
1285 if (get_property(node, "gpio-hog")) in check_gpios_property()
1288 for_each_property(node, prop) { in check_gpios_property()
1297 check_property_phandle_args(c, dti, node, prop, &provider); in check_gpios_property()
1305 struct node *node) in check_deprecated_gpio_property() argument
1309 for_each_property(node, prop) { in check_deprecated_gpio_property()
1319 FAIL_PROP(c, dti, node, prop, in check_deprecated_gpio_property()
1326 static bool node_is_interrupt_provider(struct node *node) in node_is_interrupt_provider() argument
1330 prop = get_property(node, "interrupt-controller"); in node_is_interrupt_provider()
1334 prop = get_property(node, "interrupt-map"); in node_is_interrupt_provider()
1342 struct node *node) in check_interrupts_property() argument
1344 struct node *root = dti->dt; in check_interrupts_property()
1345 struct node *irq_node = NULL, *parent = node; in check_interrupts_property()
1349 irq_prop = get_property(node, "interrupts"); in check_interrupts_property()
1354 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu", in check_interrupts_property()
1358 if (parent != node && node_is_interrupt_provider(parent)) { in check_interrupts_property()
1387 FAIL(c, dti, node, "Missing interrupt-parent"); in check_interrupts_property()
1399 FAIL_PROP(c, dti, node, prop, in check_interrupts_property()
1415 struct node *node) in check_graph_nodes() argument
1417 struct node *child; in check_graph_nodes()
1419 for_each_child(node, child) { in check_graph_nodes()
1424 node->bus = &graph_port_bus; in check_graph_nodes()
1427 if (!node->parent->bus && in check_graph_nodes()
1428 (streq(node->parent->name, "ports") || get_property(node, "reg"))) in check_graph_nodes()
1429 node->parent->bus = &graph_ports_bus; in check_graph_nodes()
1438 struct node *node) in check_graph_child_address() argument
1441 struct node *child; in check_graph_child_address()
1443 if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus) in check_graph_child_address()
1446 for_each_child(node, child) { in check_graph_child_address()
1456 if (cnt == 1 && node->addr_cells != -1) in check_graph_child_address()
1457 …FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not nece… in check_graph_child_address()
1458 node->children->name); in check_graph_child_address()
1463 struct node *node) in check_graph_reg() argument
1466 const char *unitname = get_unitname(node); in check_graph_reg()
1469 prop = get_property(node, "reg"); in check_graph_reg()
1474 FAIL(c, dti, node, "graph node malformed 'reg' property"); in check_graph_reg()
1480 FAIL(c, dti, node, "graph node unit address error, expected \"%s\"", in check_graph_reg()
1483 if (node->parent->addr_cells != 1) in check_graph_reg()
1484 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"), in check_graph_reg()
1486 node->parent->addr_cells); in check_graph_reg()
1487 if (node->parent->size_cells != 0) in check_graph_reg()
1488 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"), in check_graph_reg()
1490 node->parent->size_cells); in check_graph_reg()
1494 struct node *node) in check_graph_port() argument
1496 if (node->bus != &graph_port_bus) in check_graph_port()
1499 if (!strprefixeq(node->name, node->basenamelen, "port")) in check_graph_port()
1500 FAIL(c, dti, node, "graph port node name should be 'port'"); in check_graph_port()
1502 check_graph_reg(c, dti, node); in check_graph_port()
1506 static struct node *get_remote_endpoint(struct check *c, struct dt_info *dti, in get_remote_endpoint()
1507 struct node *endpoint) in get_remote_endpoint()
1510 struct node *node; in get_remote_endpoint() local
1522 node = get_node_by_phandle(dti->dt, phandle); in get_remote_endpoint()
1523 if (!node) in get_remote_endpoint()
1526 return node; in get_remote_endpoint()
1530 struct node *node) in check_graph_endpoint() argument
1532 struct node *remote_node; in check_graph_endpoint()
1534 if (!node->parent || node->parent->bus != &graph_port_bus) in check_graph_endpoint()
1537 if (!strprefixeq(node->name, node->basenamelen, "endpoint")) in check_graph_endpoint()
1538 FAIL(c, dti, node, "graph endpont node name should be 'endpoint'"); in check_graph_endpoint()
1540 check_graph_reg(c, dti, node); in check_graph_endpoint()
1542 remote_node = get_remote_endpoint(c, dti, node); in check_graph_endpoint()
1546 if (get_remote_endpoint(c, dti, remote_node) != node) in check_graph_endpoint()
1547 FAIL(c, dti, node, "graph connection to node '%s' is not bidirectional", in check_graph_endpoint()