Lines Matching refs:node

29 typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node);
62 struct node *node,
76 else if (node && node->srcpos)
77 pos = node->srcpos;
92 if (node) {
94 xasprintf_append(&str, "%s:%s: ", node->fullpath, prop->name);
96 xasprintf_append(&str, "%s: ", node->fullpath);
106 pos = node->srcpos;
119 #define FAIL(c, dti, node, ...) \
123 check_msg((c), dti, node, NULL, __VA_ARGS__); \
126 #define FAIL_PROP(c, dti, node, prop, ...) \
130 check_msg((c), dti, node, prop, __VA_ARGS__); \
134 static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
136 struct node *child;
138 TRACE(c, "%s", node->fullpath);
140 c->fn(c, dti, node);
142 for_each_child(node, child)
148 struct node *dt = dti->dt;
192 struct node *node)
194 FAIL(c, dti, node, "always_fail check");
199 struct node *node)
204 prop = get_property(node, propname);
209 FAIL_PROP(c, dti, node, prop, "property is not a string");
217 struct node *node)
224 prop = get_property(node, propname);
233 FAIL_PROP(c, dti, node, prop, "property is not a string list");
246 struct node *node)
251 prop = get_property(node, propname);
256 FAIL_PROP(c, dti, node, prop, "property is not a single cell");
268 struct node *node)
270 struct node *child, *child2;
272 for_each_child(node, child)
277 FAIL(c, dti, child2, "Duplicate node name");
282 struct node *node)
286 for_each_property(node, prop) {
291 FAIL_PROP(c, dti, node, prop, "Duplicate property name");
304 struct node *node)
306 int n = strspn(node->name, c->data);
308 if (n < strlen(node->name))
309 FAIL(c, dti, node, "Bad character '%c' in node name",
310 node->name[n]);
315 struct node *node)
317 int n = strspn(node->name, c->data);
319 if (n < node->basenamelen)
320 FAIL(c, dti, node, "Character '%c' not recommended in node name",
321 node->name[n]);
326 struct node *node)
328 if (strchr(get_unitname(node), '@'))
329 FAIL(c, dti, node, "multiple '@' characters in node name");
334 struct node *node)
336 const char *unitname = get_unitname(node);
337 struct property *prop = get_property(node, "reg");
339 if (get_subnode(node, "__overlay__")) {
345 prop = get_property(node, "ranges");
352 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name");
355 FAIL(c, dti, node, "node has a unit name, but no reg or ranges property");
361 struct node *node)
365 for_each_property(node, prop) {
369 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name",
377 struct node *node)
381 for_each_property(node, prop) {
401 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name",
408 #define DESCLABEL_ARGS(node,prop,mark) \
412 ((prop) ? "' in " : ""), (node)->fullpath
415 const char *label, struct node *node,
418 struct node *dt = dti->dt;
419 struct node *othernode = NULL;
434 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
435 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT
437 label, DESCLABEL_ARGS(node, prop, mark),
442 struct node *node)
447 for_each_label(node->labels, l)
448 check_duplicate_label(c, dti, l->label, node, NULL, NULL);
450 for_each_property(node, prop) {
454 check_duplicate_label(c, dti, l->label, node, prop, NULL);
457 check_duplicate_label(c, dti, m->ref, node, prop, m);
463 struct node *node, const char *propname)
465 struct node *root = dti->dt;
470 prop = get_property(node, propname);
475 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property",
483 if (node != get_node_by_ref(root, m->ref))
484 /* "Set this node's phandle equal to some
485 * other node's phandle". That's nonsensical
487 FAIL(c, dti, node, "%s is a reference to another node",
490 /* But setting this node's phandle equal to its own
492 * phandle for this node, even if it's not otherwise
501 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property",
510 struct node *node)
512 struct node *root = dti->dt;
513 struct node *other;
517 assert(!node->phandle);
519 phandle = check_phandle_prop(c, dti, node, "phandle");
521 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle");
528 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'"
535 if (other && (other != node)) {
536 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)",
541 node->phandle = phandle;
546 struct node *node)
550 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
559 if ((prop->val.len != node->basenamelen+1)
560 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
561 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead"
562 " of base node name)", prop->val.val);
580 struct node *node)
582 struct node *dt = dti->dt;
585 for_each_property(node, prop) {
587 struct node *refnode;
596 FAIL(c, dti, node, "Reference to non-existent node or "
615 struct node *node)
617 struct node *dt = dti->dt;
620 for_each_property(node, prop) {
622 struct node *refnode;
630 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n",
646 struct node *node)
648 if (generate_symbols && node->labels)
650 if (node->omit_if_unused && !node->is_referenced)
651 delete_node(node);
670 struct node *node)
674 for_each_property(node, prop) {
680 check_is_string_list(c, dti, node);
686 struct node *node)
690 if (!streq(node->name, "aliases"))
693 for_each_property(node, prop) {
700 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)",
705 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'");
711 struct node *node)
715 node->addr_cells = -1;
716 node->size_cells = -1;
718 prop = get_property(node, "#address-cells");
720 node->addr_cells = propval_cell(prop);
722 prop = get_property(node, "#size-cells");
724 node->size_cells = propval_cell(prop);
735 struct node *node)
740 prop = get_property(node, "reg");
744 if (!node->parent) {
745 FAIL(c, dti, node, "Root node has a \"reg\" property");
750 FAIL_PROP(c, dti, node, prop, "property is empty");
752 addr_cells = node_addr_cells(node->parent);
753 size_cells = node_size_cells(node->parent);
757 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) "
764 struct node *node)
770 prop = get_property(node, ranges);
774 if (!node->parent) {
775 FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
780 p_addr_cells = node_addr_cells(node->parent);
781 p_size_cells = node_size_cells(node->parent);
782 c_addr_cells = node_addr_cells(node);
783 c_size_cells = node_size_cells(node);
788 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
790 ranges, c_addr_cells, node->parent->fullpath,
793 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
795 ranges, c_size_cells, node->parent->fullpath,
798 FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
811 static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node)
816 prop = get_property(node, "device_type");
820 node->bus = &pci_bus;
822 if (!strprefixeq(node->name, node->basenamelen, "pci") &&
823 !strprefixeq(node->name, node->basenamelen, "pcie"))
824 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\"");
826 prop = get_property(node, "ranges");
828 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)");
830 if (node_addr_cells(node) != 3)
831 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
832 if (node_size_cells(node) != 2)
833 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
835 prop = get_property(node, "bus-range");
840 FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
845 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
847 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256");
852 static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node)
858 if (!node->parent || (node->parent->bus != &pci_bus))
861 prop = get_property(node, "reg");
868 prop = get_property(node->parent, "bus-range");
877 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
882 static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node)
885 const char *unitname = get_unitname(node);
890 if (!node->parent || (node->parent->bus != &pci_bus))
893 prop = get_property(node, "reg");
899 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
906 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space");
908 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0");
920 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"",
929 static bool node_is_compatible(struct node *node, const char *compat)
934 prop = get_property(node, "compatible");
946 static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
948 if (node_is_compatible(node, "simple-bus"))
949 node->bus = &simple_bus;
954 static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
957 const char *unitname = get_unitname(node);
963 if (!node->parent || (node->parent->bus != &simple_bus))
966 prop = get_property(node, "reg");
970 prop = get_property(node, "ranges");
973 cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
977 if (node->parent->parent && !(node->bus == &simple_bus))
978 FAIL(c, dti, node, "missing or empty reg/ranges property");
982 size = node_addr_cells(node->parent);
988 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
997 static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
999 if (strprefixeq(node->name, node->basenamelen, "i2c-bus") ||
1000 strprefixeq(node->name, node->basenamelen, "i2c-arb")) {
1001 node->bus = &i2c_bus;
1002 } else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
1003 struct node *child;
1004 for_each_child(node, child) {
1005 if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
1008 node->bus = &i2c_bus;
1012 if (!node->children)
1015 if (node_addr_cells(node) != 1)
1016 FAIL(c, dti, node, "incorrect #address-cells for I2C bus");
1017 if (node_size_cells(node) != 0)
1018 FAIL(c, dti, node, "incorrect #size-cells for I2C bus");
1026 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1029 const char *unitname = get_unitname(node);
1035 if (!node->parent || (node->parent->bus != &i2c_bus))
1038 prop = get_property(node, "reg");
1043 FAIL(c, dti, node, "missing or empty reg property");
1052 FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
1061 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
1064 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 7-bits, got \"0x%x\". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property",
1074 static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
1078 if (strprefixeq(node->name, node->basenamelen, "spi")) {
1079 node->bus = &spi_bus;
1081 /* Try to detect SPI buses which don't have proper node name */
1082 struct node *child;
1084 if (node_addr_cells(node) != 1 || node_size_cells(node) != 0)
1087 for_each_child(node, child) {
1091 node->bus = &spi_bus;
1095 if (node->bus == &spi_bus)
1099 if (node->bus == &spi_bus && get_property(node, "reg"))
1100 FAIL(c, dti, node, "node name for SPI buses should be 'spi'");
1102 if (node->bus != &spi_bus || !node->children)
1105 if (get_property(node, "spi-slave"))
1107 if (node_addr_cells(node) != spi_addr_cells)
1108 FAIL(c, dti, node, "incorrect #address-cells for SPI bus");
1109 if (node_size_cells(node) != 0)
1110 FAIL(c, dti, node, "incorrect #size-cells for SPI bus");
1115 static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1118 const char *unitname = get_unitname(node);
1123 if (!node->parent || (node->parent->bus != &spi_bus))
1126 if (get_property(node->parent, "spi-slave"))
1129 prop = get_property(node, "reg");
1134 FAIL(c, dti, node, "missing or empty reg property");
1141 FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"",
1147 struct node *node)
1149 const char *unitname = get_unitname(node);
1151 if (node->parent && node->parent->bus)
1158 FAIL(c, dti, node, "unit name should not have leading \"0x\"");
1163 FAIL(c, dti, node, "unit name should not have leading 0s");
1172 struct node *node)
1176 if (!node->parent)
1177 return; /* Ignore root node */
1179 reg = get_property(node, "reg");
1180 ranges = get_property(node, "ranges");
1185 if (node->parent->addr_cells == -1)
1186 FAIL(c, dti, node, "Relying on default #address-cells value");
1188 if (node->parent->size_cells == -1)
1189 FAIL(c, dti, node, "Relying on default #size-cells value");
1195 struct node *node)
1198 struct node *child;
1201 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
1204 if (get_property(node, "ranges") || !node->children)
1207 for_each_child(node, child) {
1214 FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" property");
1218 static bool node_is_disabled(struct node *node)
1222 prop = get_property(node, "status");
1234 struct node *node,
1237 struct node *childa;
1239 if (node->addr_cells < 0 || node->size_cells < 0)
1242 if (!node->children)
1245 for_each_child(node, childa) {
1246 struct node *childb;
1255 for_each_child(node, childb) {
1264 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
1270 struct node *node)
1272 check_unique_unit_address_common(c, dti, node, false);
1277 struct node *node)
1279 check_unique_unit_address_common(c, dti, node, true);
1286 struct node *node)
1288 struct node *dt = dti->dt;
1289 struct node *chosen;
1292 if (node != dt)
1302 FAIL_PROP(c, dti, node, prop,
1309 struct node *node)
1311 if (!streq(node->name, "chosen"))
1314 if (node->parent != dti->dt)
1315 FAIL(c, dti, node, "chosen node must be at root node");
1320 struct node *node)
1324 if (!streq(node->name, "chosen"))
1327 prop = get_property(node, "bootargs");
1332 check_is_string(c, dti, node);
1337 struct node *node)
1341 if (!streq(node->name, "chosen"))
1344 prop = get_property(node, "stdout-path");
1346 prop = get_property(node, "linux,stdout-path");
1349 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead");
1353 check_is_string(c, dti, node);
1365 struct node *node,
1369 struct node *root = dti->dt;
1373 FAIL_PROP(c, dti, node, prop,
1380 struct node *provider_node;
1406 FAIL_PROP(c, dti, node, prop,
1413 FAIL_PROP(c, dti, node, prop,
1414 "Could not get phandle node for (cell %d)",
1425 FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])",
1433 FAIL_PROP(c, dti, node, prop,
1442 struct node *node)
1447 prop = get_property(node, provider->prop_name);
1451 check_property_phandle_args(c, dti, node, prop, provider);
1498 struct node *node)
1503 if (get_property(node, "gpio-hog"))
1506 for_each_property(node, prop) {
1515 check_property_phandle_args(c, dti, node, prop, &provider);
1523 struct node *node)
1527 for_each_property(node, prop) {
1537 FAIL_PROP(c, dti, node, prop,
1544 static bool node_is_interrupt_provider(struct node *node)
1548 prop = get_property(node, "interrupt-controller");
1552 prop = get_property(node, "interrupt-map");
1561 struct node *node)
1565 if (!node_is_interrupt_provider(node))
1568 prop = get_property(node, "#interrupt-cells");
1570 FAIL(c, dti, node,
1573 prop = get_property(node, "#address-cells");
1575 FAIL(c, dti, node,
1582 struct node *node)
1584 struct node *root = dti->dt;
1585 struct node *irq_node = NULL, *parent = node;
1589 irq_prop = get_property(node, "interrupts");
1594 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu",
1598 if (parent != node && node_is_interrupt_provider(parent)) {
1631 FAIL(c, dti, node, "Missing interrupt-parent");
1643 FAIL_PROP(c, dti, node, prop,
1659 struct node *node)
1661 struct node *child;
1663 for_each_child(node, child) {
1668 node->bus = &graph_port_bus;
1671 if (!node->parent->bus &&
1672 (streq(node->parent->name, "ports") || get_property(node, "reg")))
1673 node->parent->bus = &graph_ports_bus;
1682 struct node *node)
1685 struct node *child;
1687 if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
1690 for_each_child(node, child) {
1700 if (cnt == 1 && node->addr_cells != -1)
1701 FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
1702 node->children->name);
1707 struct node *node)
1710 const char *unitname = get_unitname(node);
1713 prop = get_property(node, "reg");
1718 FAIL(c, dti, node, "graph node malformed 'reg' property");
1724 FAIL(c, dti, node, "graph node unit address error, expected \"%s\"",
1727 if (node->parent->addr_cells != 1)
1728 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"),
1729 "graph node '#address-cells' is %d, must be 1",
1730 node->parent->addr_cells);
1731 if (node->parent->size_cells != 0)
1732 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"),
1733 "graph node '#size-cells' is %d, must be 0",
1734 node->parent->size_cells);
1738 struct node *node)
1740 if (node->bus != &graph_port_bus)
1743 if (!strprefixeq(node->name, node->basenamelen, "port"))
1744 FAIL(c, dti, node, "graph port node name should be 'port'");
1746 check_graph_reg(c, dti, node);
1750 static struct node *get_remote_endpoint(struct check *c, struct dt_info *dti,
1751 struct node *endpoint)
1754 struct node *node;
1766 node = get_node_by_phandle(dti->dt, phandle);
1767 if (!node)
1770 return node;
1774 struct node *node)
1776 struct node *remote_node;
1778 if (!node->parent || node->parent->bus != &graph_port_bus)
1781 if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
1782 FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'");
1784 check_graph_reg(c, dti, node);
1786 remote_node = get_remote_endpoint(c, dti, node);
1790 if (get_remote_endpoint(c, dti, remote_node) != node)
1791 FAIL(c, dti, node, "graph connection to node '%s' is not bidirectional",