Lines Matching defs: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;
120 #define FAIL(c, dti, node, ...) \
124 check_msg((c), dti, node, NULL, __VA_ARGS__); \
127 #define FAIL_PROP(c, dti, node, prop, ...) \
131 check_msg((c), dti, node, prop, __VA_ARGS__); \
135 static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
137 struct node *child;
139 TRACE(c, "%s", node->fullpath);
141 c->fn(c, dti, node);
143 for_each_child(node, child)
157 struct node *dt = dti->dt;
201 struct node *node)
203 FAIL(c, dti, node, "always_fail check");
208 struct node *node)
213 prop = get_property(node, propname);
218 FAIL_PROP(c, dti, node, prop, "property is not a string");
226 struct node *node)
233 prop = get_property(node, propname);
242 FAIL_PROP(c, dti, node, prop, "property is not a string list");
255 struct node *node)
260 prop = get_property(node, propname);
265 FAIL_PROP(c, dti, node, prop, "property is not a single cell");
277 struct node *node)
279 struct node *child, *child2;
281 for_each_child(node, child)
286 FAIL(c, dti, child2, "Duplicate node name");
291 struct node *node)
295 for_each_property(node, prop) {
300 FAIL_PROP(c, dti, node, prop, "Duplicate property name");
314 struct node *node)
316 size_t n = strspn(node->name, c->data);
318 if (n < strlen(node->name))
319 FAIL(c, dti, node, "Bad character '%c' in node name",
320 node->name[n]);
325 struct node *node)
327 int n = strspn(node->name, c->data);
329 if (n < node->basenamelen)
330 FAIL(c, dti, node, "Character '%c' not recommended in node name",
331 node->name[n]);
336 struct node *node)
338 if (strchr(get_unitname(node), '@'))
339 FAIL(c, dti, node, "multiple '@' characters in node name");
344 struct node *node)
346 if (node->basenamelen == 0 && node->parent != NULL)
347 FAIL(c, dti, node, "Empty node name");
353 struct node *node)
355 if (!node->parent)
358 if (get_property(node->parent, node->name)) {
359 FAIL(c, dti, node, "node name and property name conflict");
366 struct node *node)
368 const char *unitname = get_unitname(node);
369 struct property *prop = get_property(node, "reg");
371 if (get_subnode(node, "__overlay__")) {
377 prop = get_property(node, "ranges");
384 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name");
387 FAIL(c, dti, node, "node has a unit name, but no reg or ranges property");
393 struct node *node)
397 for_each_property(node, prop) {
401 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name",
409 struct node *node)
413 for_each_property(node, prop) {
433 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name",
440 #define DESCLABEL_ARGS(node,prop,mark) \
444 ((prop) ? "' in " : ""), (node)->fullpath
447 const char *label, struct node *node,
450 struct node *dt = dti->dt;
451 struct node *othernode = NULL;
466 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
467 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT
469 label, DESCLABEL_ARGS(node, prop, mark),
474 struct node *node)
479 for_each_label(node->labels, l)
480 check_duplicate_label(c, dti, l->label, node, NULL, NULL);
482 for_each_property(node, prop) {
486 check_duplicate_label(c, dti, l->label, node, prop, NULL);
489 check_duplicate_label(c, dti, m->ref, node, prop, m);
495 struct node *node, const char *propname)
497 struct node *root = dti->dt;
502 prop = get_property(node, propname);
507 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property",
515 if (node != get_node_by_ref(root, m->ref))
516 /* "Set this node's phandle equal to some
517 * other node's phandle". That's nonsensical
519 FAIL(c, dti, node, "%s is a reference to another node",
522 /* But setting this node's phandle equal to its own
524 * phandle for this node, even if it's not otherwise
533 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property",
542 struct node *node)
544 struct node *root = dti->dt;
545 struct node *other;
549 assert(!node->phandle);
551 phandle = check_phandle_prop(c, dti, node, "phandle");
553 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle");
560 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'"
567 if (other && (other != node)) {
568 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)",
573 node->phandle = phandle;
578 struct node *node)
582 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
591 if ((prop->val.len != node->basenamelen + 1U)
592 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
593 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead"
594 " of base node name)", prop->val.val);
612 struct node *node)
614 struct node *dt = dti->dt;
617 for_each_property(node, prop) {
619 struct node *refnode;
628 FAIL(c, dti, node, "Reference to non-existent node or "
647 struct node *node)
649 struct node *dt = dti->dt;
652 for_each_property(node, prop) {
654 struct node *refnode;
662 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n",
678 struct node *node)
680 if (generate_symbols && node->labels)
682 if (node->omit_if_unused && !node->is_referenced)
683 delete_node(node);
701 struct node *node)
705 for_each_property(node, prop) {
710 check_is_string_list(c, dti, node);
716 struct node *node)
720 if (!streq(node->name, "aliases"))
723 for_each_property(node, prop) {
732 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)",
738 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'");
744 struct node *node)
748 node->addr_cells = -1;
749 node->size_cells = -1;
751 prop = get_property(node, "#address-cells");
753 node->addr_cells = propval_cell(prop);
755 prop = get_property(node, "#size-cells");
757 node->size_cells = propval_cell(prop);
768 struct node *node)
773 prop = get_property(node, "reg");
777 if (!node->parent) {
778 FAIL(c, dti, node, "Root node has a \"reg\" property");
783 FAIL_PROP(c, dti, node, prop, "property is empty");
785 addr_cells = node_addr_cells(node->parent);
786 size_cells = node_size_cells(node->parent);
790 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) "
797 struct node *node)
803 prop = get_property(node, ranges);
807 if (!node->parent) {
808 FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
813 p_addr_cells = node_addr_cells(node->parent);
814 p_size_cells = node_size_cells(node->parent);
815 c_addr_cells = node_addr_cells(node);
816 c_size_cells = node_size_cells(node);
821 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
823 ranges, c_addr_cells, node->parent->fullpath,
826 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
828 ranges, c_size_cells, node->parent->fullpath,
831 FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
844 static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node)
849 prop = get_property(node, "device_type");
853 node->bus = &pci_bus;
855 if (!strprefixeq(node->name, node->basenamelen, "pci") &&
856 !strprefixeq(node->name, node->basenamelen, "pcie"))
857 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\"");
859 prop = get_property(node, "ranges");
861 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)");
863 if (node_addr_cells(node) != 3)
864 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
865 if (node_size_cells(node) != 2)
866 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
868 prop = get_property(node, "bus-range");
873 FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
878 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
880 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256");
885 static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node)
891 if (!node->parent || (node->parent->bus != &pci_bus))
894 prop = get_property(node, "reg");
901 prop = get_property(node->parent, "bus-range");
910 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
915 static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node)
918 const char *unitname = get_unitname(node);
923 if (!node->parent || (node->parent->bus != &pci_bus))
926 prop = get_property(node, "reg");
932 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
939 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space");
941 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0");
953 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"",
962 static bool node_is_compatible(struct node *node, const char *compat)
967 prop = get_property(node, "compatible");
979 static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
981 if (node_is_compatible(node, "simple-bus"))
982 node->bus = &simple_bus;
987 static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
990 const char *unitname = get_unitname(node);
996 if (!node->parent || (node->parent->bus != &simple_bus))
999 prop = get_property(node, "reg");
1003 prop = get_property(node, "ranges");
1006 cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
1010 if (node->parent->parent && !(node->bus == &simple_bus))
1011 FAIL(c, dti, node, "missing or empty reg/ranges property");
1015 size = node_addr_cells(node->parent);
1021 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
1030 static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
1032 if (strprefixeq(node->name, node->basenamelen, "i2c-bus") ||
1033 strprefixeq(node->name, node->basenamelen, "i2c-arb")) {
1034 node->bus = &i2c_bus;
1035 } else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
1036 struct node *child;
1037 for_each_child(node, child) {
1041 node->bus = &i2c_bus;
1045 if (!node->children)
1048 if (node_addr_cells(node) != 1)
1049 FAIL(c, dti, node, "incorrect #address-cells for I2C bus");
1050 if (node_size_cells(node) != 0)
1051 FAIL(c, dti, node, "incorrect #size-cells for I2C bus");
1059 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1062 const char *unitname = get_unitname(node);
1068 if (!node->parent || (node->parent->bus != &i2c_bus))
1071 prop = get_property(node, "reg");
1076 FAIL(c, dti, node, "missing or empty reg property");
1085 FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
1095 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
1098 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",
1108 static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
1112 if (strprefixeq(node->name, node->basenamelen, "spi")) {
1113 node->bus = &spi_bus;
1115 /* Try to detect SPI buses which don't have proper node name */
1116 struct node *child;
1118 if (node_addr_cells(node) != 1 || node_size_cells(node) != 0)
1121 for_each_child(node, child) {
1125 node->bus = &spi_bus;
1129 if (node->bus == &spi_bus)
1133 if (node->bus == &spi_bus && get_property(node, "reg"))
1134 FAIL(c, dti, node, "node name for SPI buses should be 'spi'");
1136 if (node->bus != &spi_bus || !node->children)
1139 if (get_property(node, "spi-slave"))
1141 if (node_addr_cells(node) != spi_addr_cells)
1142 FAIL(c, dti, node, "incorrect #address-cells for SPI bus");
1143 if (node_size_cells(node) != 0)
1144 FAIL(c, dti, node, "incorrect #size-cells for SPI bus");
1149 static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1152 const char *unitname = get_unitname(node);
1157 if (!node->parent || (node->parent->bus != &spi_bus))
1160 if (get_property(node->parent, "spi-slave"))
1163 prop = get_property(node, "reg");
1168 FAIL(c, dti, node, "missing or empty reg property");
1175 FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"",
1181 struct node *node)
1183 const char *unitname = get_unitname(node);
1185 if (node->parent && node->parent->bus)
1192 FAIL(c, dti, node, "unit name should not have leading \"0x\"");
1197 FAIL(c, dti, node, "unit name should not have leading 0s");
1206 struct node *node)
1210 if (!node->parent)
1211 return; /* Ignore root node */
1213 reg = get_property(node, "reg");
1214 ranges = get_property(node, "ranges");
1219 if (node->parent->addr_cells == -1)
1220 FAIL(c, dti, node, "Relying on default #address-cells value");
1222 if (node->parent->size_cells == -1)
1223 FAIL(c, dti, node, "Relying on default #size-cells value");
1229 struct node *node)
1231 struct node *child;
1233 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
1236 if (get_property(node, "ranges") || get_property(node, "dma-ranges") || !node->children)
1239 for_each_child(node, child) {
1242 * the parent bus (no 'ranges' property on node), children can
1251 FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" or \"ranges\" property");
1255 static bool node_is_disabled(struct node *node)
1259 prop = get_property(node, "status");
1271 struct node *node,
1274 struct node *childa;
1276 if (node->addr_cells < 0 || node->size_cells < 0)
1279 if (!node->children)
1282 for_each_child(node, childa) {
1283 struct node *childb;
1292 for_each_child(node, childb) {
1301 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
1307 struct node *node)
1309 check_unique_unit_address_common(c, dti, node, false);
1314 struct node *node)
1316 check_unique_unit_address_common(c, dti, node, true);
1323 struct node *node)
1325 struct node *dt = dti->dt;
1326 struct node *chosen;
1329 if (node != dt)
1339 FAIL_PROP(c, dti, node, prop,
1346 struct node *node)
1348 if (!streq(node->name, "chosen"))
1351 if (node->parent != dti->dt)
1352 FAIL(c, dti, node, "chosen node must be at root node");
1357 struct node *node)
1361 if (!streq(node->name, "chosen"))
1364 prop = get_property(node, "bootargs");
1369 check_is_string(c, dti, node);
1374 struct node *node)
1378 if (!streq(node->name, "chosen"))
1381 prop = get_property(node, "stdout-path");
1383 prop = get_property(node, "linux,stdout-path");
1386 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead");
1390 check_is_string(c, dti, node);
1402 struct node *node,
1406 struct node *root = dti->dt;
1410 FAIL_PROP(c, dti, node, prop,
1417 struct node *provider_node;
1444 FAIL_PROP(c, dti, node, prop,
1451 FAIL_PROP(c, dti, node, prop,
1452 "Could not get phandle node for (cell %d)",
1463 FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])",
1472 FAIL_PROP(c, dti, node, prop,
1482 struct node *node)
1487 prop = get_property(node, provider->prop_name);
1491 check_property_phandle_args(c, dti, node, prop, provider);
1532 struct node *node)
1537 if (get_property(node, "gpio-hog"))
1540 for_each_property(node, prop) {
1549 check_property_phandle_args(c, dti, node, prop, &provider);
1557 struct node *node)
1561 for_each_property(node, prop) {
1568 FAIL_PROP(c, dti, node, prop,
1575 static bool node_is_interrupt_provider(struct node *node)
1579 prop = get_property(node, "interrupt-controller");
1583 prop = get_property(node, "interrupt-map");
1592 struct node *node)
1595 bool irq_provider = node_is_interrupt_provider(node);
1597 prop = get_property(node, "#interrupt-cells");
1599 FAIL(c, dti, node,
1605 FAIL(c, dti, node,
1606 "'#interrupt-cells' found, but node is not an interrupt provider");
1614 struct node *node)
1616 struct node *root = dti->dt;
1620 irq_map_prop = get_property(node, "interrupt-map");
1624 if (node->addr_cells < 0) {
1625 FAIL(c, dti, node,
1629 cellsize = node_addr_cells(node);
1630 cellsize += propval_cell(get_property(node, "#interrupt-cells"));
1632 prop = get_property(node, "interrupt-map-mask");
1634 FAIL_PROP(c, dti, node, prop,
1639 FAIL_PROP(c, dti, node, irq_map_prop,
1647 struct node *provider_node;
1653 FAIL_PROP(c, dti, node, irq_map_prop,
1664 FAIL_PROP(c, dti, node, irq_map_prop,
1672 FAIL_PROP(c, dti, node, irq_map_prop,
1673 "Could not get phandle(%d) node for (cell %zu)",
1682 FAIL(c, dti, node, "Missing property '#interrupt-cells' in node %s or bad phandle (referred from interrupt-map[%zu])",
1691 FAIL_PROP(c, dti, node, irq_map_prop,
1692 "Missing property '#address-cells' in node %s, using 0 as fallback",
1697 FAIL_PROP(c, dti, node, irq_map_prop,
1706 struct node *node)
1708 struct node *root = dti->dt;
1709 struct node *irq_node = NULL, *parent = node;
1713 irq_prop = get_property(node, "interrupts");
1718 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu",
1722 if (parent != node && node_is_interrupt_provider(parent)) {
1755 FAIL(c, dti, node, "Missing interrupt-parent");
1767 FAIL_PROP(c, dti, node, prop,
1783 struct node *node)
1785 struct node *child;
1787 for_each_child(node, child) {
1792 /* The root node cannot be a port */
1793 if (!node->parent) {
1794 FAIL(c, dti, node, "root node contains endpoint node '%s', potentially misplaced remote-endpoint property", child->name);
1797 node->bus = &graph_port_bus;
1800 if (!node->parent->bus &&
1801 (streq(node->parent->name, "ports") || get_property(node, "reg")))
1802 node->parent->bus = &graph_ports_bus;
1811 struct node *node)
1814 const char *unitname = get_unitname(node);
1817 prop = get_property(node, "reg");
1822 FAIL(c, dti, node, "graph node malformed 'reg' property");
1828 FAIL(c, dti, node, "graph node unit address error, expected \"%s\"",
1831 if (node->parent->addr_cells != 1)
1832 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"),
1833 "graph node '#address-cells' is %d, must be 1",
1834 node->parent->addr_cells);
1835 if (node->parent->size_cells != 0)
1836 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"),
1837 "graph node '#size-cells' is %d, must be 0",
1838 node->parent->size_cells);
1842 struct node *node)
1844 if (node->bus != &graph_port_bus)
1847 check_graph_reg(c, dti, node);
1853 if (!strprefixeq(node->name, node->basenamelen, "port"))
1854 FAIL(c, dti, node, "graph port node name should be 'port'");
1858 static struct node *get_remote_endpoint(struct check *c, struct dt_info *dti,
1859 struct node *endpoint)
1862 struct node *node;
1874 node = get_node_by_phandle(dti->dt, phandle);
1875 if (!node)
1878 return node;
1882 struct node *node)
1884 struct node *remote_node;
1886 if (!node->parent || node->parent->bus != &graph_port_bus)
1889 check_graph_reg(c, dti, node);
1895 if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
1896 FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'");
1898 remote_node = get_remote_endpoint(c, dti, node);
1902 if (get_remote_endpoint(c, dti, remote_node) != node)
1903 FAIL(c, dti, node, "graph connection to node '%s' is not bidirectional",