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)
156 struct node *dt = dti->dt;
200 struct node *node)
202 FAIL(c, dti, node, "always_fail check");
207 struct node *node)
212 prop = get_property(node, propname);
217 FAIL_PROP(c, dti, node, prop, "property is not a string");
225 struct node *node)
232 prop = get_property(node, propname);
241 FAIL_PROP(c, dti, node, prop, "property is not a string list");
254 struct node *node)
259 prop = get_property(node, propname);
264 FAIL_PROP(c, dti, node, prop, "property is not a single cell");
276 struct node *node)
278 struct node *child, *child2;
280 for_each_child(node, child)
285 FAIL(c, dti, child2, "Duplicate node name");
290 struct node *node)
294 for_each_property(node, prop) {
299 FAIL_PROP(c, dti, node, prop, "Duplicate property name");
313 struct node *node)
315 size_t n = strspn(node->name, c->data);
317 if (n < strlen(node->name))
318 FAIL(c, dti, node, "Bad character '%c' in node name",
319 node->name[n]);
324 struct node *node)
326 int n = strspn(node->name, c->data);
328 if (n < node->basenamelen)
329 FAIL(c, dti, node, "Character '%c' not recommended in node name",
330 node->name[n]);
335 struct node *node)
337 if (strchr(get_unitname(node), '@'))
338 FAIL(c, dti, node, "multiple '@' characters in node name");
344 struct node *node)
346 if (!node->parent)
349 if (get_property(node->parent, node->name)) {
350 FAIL(c, dti, node, "node name and property name conflict");
357 struct node *node)
359 const char *unitname = get_unitname(node);
360 struct property *prop = get_property(node, "reg");
362 if (get_subnode(node, "__overlay__")) {
368 prop = get_property(node, "ranges");
375 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name");
378 FAIL(c, dti, node, "node has a unit name, but no reg or ranges property");
384 struct node *node)
388 for_each_property(node, prop) {
392 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name",
400 struct node *node)
404 for_each_property(node, prop) {
424 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name",
431 #define DESCLABEL_ARGS(node,prop,mark) \
435 ((prop) ? "' in " : ""), (node)->fullpath
438 const char *label, struct node *node,
441 struct node *dt = dti->dt;
442 struct node *othernode = NULL;
457 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
458 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT
460 label, DESCLABEL_ARGS(node, prop, mark),
465 struct node *node)
470 for_each_label(node->labels, l)
471 check_duplicate_label(c, dti, l->label, node, NULL, NULL);
473 for_each_property(node, prop) {
477 check_duplicate_label(c, dti, l->label, node, prop, NULL);
480 check_duplicate_label(c, dti, m->ref, node, prop, m);
486 struct node *node, const char *propname)
488 struct node *root = dti->dt;
493 prop = get_property(node, propname);
498 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property",
506 if (node != get_node_by_ref(root, m->ref))
507 /* "Set this node's phandle equal to some
508 * other node's phandle". That's nonsensical
510 FAIL(c, dti, node, "%s is a reference to another node",
513 /* But setting this node's phandle equal to its own
515 * phandle for this node, even if it's not otherwise
524 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property",
533 struct node *node)
535 struct node *root = dti->dt;
536 struct node *other;
540 assert(!node->phandle);
542 phandle = check_phandle_prop(c, dti, node, "phandle");
544 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle");
551 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'"
558 if (other && (other != node)) {
559 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)",
564 node->phandle = phandle;
569 struct node *node)
573 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
582 if ((prop->val.len != node->basenamelen + 1U)
583 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
584 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead"
585 " of base node name)", prop->val.val);
603 struct node *node)
605 struct node *dt = dti->dt;
608 for_each_property(node, prop) {
610 struct node *refnode;
619 FAIL(c, dti, node, "Reference to non-existent node or "
638 struct node *node)
640 struct node *dt = dti->dt;
643 for_each_property(node, prop) {
645 struct node *refnode;
653 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n",
669 struct node *node)
671 if (generate_symbols && node->labels)
673 if (node->omit_if_unused && !node->is_referenced)
674 delete_node(node);
692 struct node *node)
696 for_each_property(node, prop) {
701 check_is_string_list(c, dti, node);
707 struct node *node)
711 if (!streq(node->name, "aliases"))
714 for_each_property(node, prop) {
721 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)",
726 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'");
732 struct node *node)
736 node->addr_cells = -1;
737 node->size_cells = -1;
739 prop = get_property(node, "#address-cells");
741 node->addr_cells = propval_cell(prop);
743 prop = get_property(node, "#size-cells");
745 node->size_cells = propval_cell(prop);
756 struct node *node)
761 prop = get_property(node, "reg");
765 if (!node->parent) {
766 FAIL(c, dti, node, "Root node has a \"reg\" property");
771 FAIL_PROP(c, dti, node, prop, "property is empty");
773 addr_cells = node_addr_cells(node->parent);
774 size_cells = node_size_cells(node->parent);
778 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) "
785 struct node *node)
791 prop = get_property(node, ranges);
795 if (!node->parent) {
796 FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
801 p_addr_cells = node_addr_cells(node->parent);
802 p_size_cells = node_size_cells(node->parent);
803 c_addr_cells = node_addr_cells(node);
804 c_size_cells = node_size_cells(node);
809 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
811 ranges, c_addr_cells, node->parent->fullpath,
814 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
816 ranges, c_size_cells, node->parent->fullpath,
819 FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
832 static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node)
837 prop = get_property(node, "device_type");
841 node->bus = &pci_bus;
843 if (!strprefixeq(node->name, node->basenamelen, "pci") &&
844 !strprefixeq(node->name, node->basenamelen, "pcie"))
845 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\"");
847 prop = get_property(node, "ranges");
849 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)");
851 if (node_addr_cells(node) != 3)
852 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
853 if (node_size_cells(node) != 2)
854 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
856 prop = get_property(node, "bus-range");
861 FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
866 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
868 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256");
873 static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node)
879 if (!node->parent || (node->parent->bus != &pci_bus))
882 prop = get_property(node, "reg");
889 prop = get_property(node->parent, "bus-range");
898 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
903 static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node)
906 const char *unitname = get_unitname(node);
911 if (!node->parent || (node->parent->bus != &pci_bus))
914 prop = get_property(node, "reg");
920 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
927 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space");
929 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0");
941 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"",
950 static bool node_is_compatible(struct node *node, const char *compat)
955 prop = get_property(node, "compatible");
967 static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
969 if (node_is_compatible(node, "simple-bus"))
970 node->bus = &simple_bus;
975 static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
978 const char *unitname = get_unitname(node);
984 if (!node->parent || (node->parent->bus != &simple_bus))
987 prop = get_property(node, "reg");
991 prop = get_property(node, "ranges");
994 cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
998 if (node->parent->parent && !(node->bus == &simple_bus))
999 FAIL(c, dti, node, "missing or empty reg/ranges property");
1003 size = node_addr_cells(node->parent);
1009 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
1018 static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
1020 if (strprefixeq(node->name, node->basenamelen, "i2c-bus") ||
1021 strprefixeq(node->name, node->basenamelen, "i2c-arb")) {
1022 node->bus = &i2c_bus;
1023 } else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
1024 struct node *child;
1025 for_each_child(node, child) {
1026 if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
1029 node->bus = &i2c_bus;
1033 if (!node->children)
1036 if (node_addr_cells(node) != 1)
1037 FAIL(c, dti, node, "incorrect #address-cells for I2C bus");
1038 if (node_size_cells(node) != 0)
1039 FAIL(c, dti, node, "incorrect #size-cells for I2C bus");
1047 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1050 const char *unitname = get_unitname(node);
1056 if (!node->parent || (node->parent->bus != &i2c_bus))
1059 prop = get_property(node, "reg");
1064 FAIL(c, dti, node, "missing or empty reg property");
1073 FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
1082 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
1085 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",
1095 static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
1099 if (strprefixeq(node->name, node->basenamelen, "spi")) {
1100 node->bus = &spi_bus;
1102 /* Try to detect SPI buses which don't have proper node name */
1103 struct node *child;
1105 if (node_addr_cells(node) != 1 || node_size_cells(node) != 0)
1108 for_each_child(node, child) {
1112 node->bus = &spi_bus;
1116 if (node->bus == &spi_bus)
1120 if (node->bus == &spi_bus && get_property(node, "reg"))
1121 FAIL(c, dti, node, "node name for SPI buses should be 'spi'");
1123 if (node->bus != &spi_bus || !node->children)
1126 if (get_property(node, "spi-slave"))
1128 if (node_addr_cells(node) != spi_addr_cells)
1129 FAIL(c, dti, node, "incorrect #address-cells for SPI bus");
1130 if (node_size_cells(node) != 0)
1131 FAIL(c, dti, node, "incorrect #size-cells for SPI bus");
1136 static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
1139 const char *unitname = get_unitname(node);
1144 if (!node->parent || (node->parent->bus != &spi_bus))
1147 if (get_property(node->parent, "spi-slave"))
1150 prop = get_property(node, "reg");
1155 FAIL(c, dti, node, "missing or empty reg property");
1162 FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"",
1168 struct node *node)
1170 const char *unitname = get_unitname(node);
1172 if (node->parent && node->parent->bus)
1179 FAIL(c, dti, node, "unit name should not have leading \"0x\"");
1184 FAIL(c, dti, node, "unit name should not have leading 0s");
1193 struct node *node)
1197 if (!node->parent)
1198 return; /* Ignore root node */
1200 reg = get_property(node, "reg");
1201 ranges = get_property(node, "ranges");
1206 if (node->parent->addr_cells == -1)
1207 FAIL(c, dti, node, "Relying on default #address-cells value");
1209 if (node->parent->size_cells == -1)
1210 FAIL(c, dti, node, "Relying on default #size-cells value");
1216 struct node *node)
1219 struct node *child;
1222 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
1225 if (get_property(node, "ranges") || !node->children)
1228 for_each_child(node, child) {
1235 FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" property");
1239 static bool node_is_disabled(struct node *node)
1243 prop = get_property(node, "status");
1255 struct node *node,
1258 struct node *childa;
1260 if (node->addr_cells < 0 || node->size_cells < 0)
1263 if (!node->children)
1266 for_each_child(node, childa) {
1267 struct node *childb;
1276 for_each_child(node, childb) {
1285 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
1291 struct node *node)
1293 check_unique_unit_address_common(c, dti, node, false);
1298 struct node *node)
1300 check_unique_unit_address_common(c, dti, node, true);
1307 struct node *node)
1309 struct node *dt = dti->dt;
1310 struct node *chosen;
1313 if (node != dt)
1323 FAIL_PROP(c, dti, node, prop,
1330 struct node *node)
1332 if (!streq(node->name, "chosen"))
1335 if (node->parent != dti->dt)
1336 FAIL(c, dti, node, "chosen node must be at root node");
1341 struct node *node)
1345 if (!streq(node->name, "chosen"))
1348 prop = get_property(node, "bootargs");
1353 check_is_string(c, dti, node);
1358 struct node *node)
1362 if (!streq(node->name, "chosen"))
1365 prop = get_property(node, "stdout-path");
1367 prop = get_property(node, "linux,stdout-path");
1370 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead");
1374 check_is_string(c, dti, node);
1386 struct node *node,
1390 struct node *root = dti->dt;
1394 FAIL_PROP(c, dti, node, prop,
1401 struct node *provider_node;
1428 FAIL_PROP(c, dti, node, prop,
1435 FAIL_PROP(c, dti, node, prop,
1436 "Could not get phandle node for (cell %d)",
1447 FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])",
1456 FAIL_PROP(c, dti, node, prop,
1466 struct node *node)
1471 prop = get_property(node, provider->prop_name);
1475 check_property_phandle_args(c, dti, node, prop, provider);
1516 struct node *node)
1521 if (get_property(node, "gpio-hog"))
1524 for_each_property(node, prop) {
1533 check_property_phandle_args(c, dti, node, prop, &provider);
1541 struct node *node)
1545 for_each_property(node, prop) {
1552 FAIL_PROP(c, dti, node, prop,
1559 static bool node_is_interrupt_provider(struct node *node)
1563 prop = get_property(node, "interrupt-controller");
1567 prop = get_property(node, "interrupt-map");
1576 struct node *node)
1579 bool irq_provider = node_is_interrupt_provider(node);
1581 prop = get_property(node, "#interrupt-cells");
1583 FAIL(c, dti, node,
1589 FAIL(c, dti, node,
1590 "'#interrupt-cells' found, but node is not an interrupt provider");
1598 struct node *node)
1600 struct node *root = dti->dt;
1604 irq_map_prop = get_property(node, "interrupt-map");
1608 if (node->addr_cells < 0) {
1609 FAIL(c, dti, node,
1613 cellsize = node_addr_cells(node);
1614 cellsize += propval_cell(get_property(node, "#interrupt-cells"));
1616 prop = get_property(node, "interrupt-map-mask");
1618 FAIL_PROP(c, dti, node, prop,
1623 FAIL_PROP(c, dti, node, irq_map_prop,
1631 struct node *provider_node;
1637 FAIL_PROP(c, dti, node, irq_map_prop,
1648 FAIL_PROP(c, dti, node, irq_map_prop,
1656 FAIL_PROP(c, dti, node, irq_map_prop,
1657 "Could not get phandle(%d) node for (cell %zu)",
1666 FAIL(c, dti, node, "Missing property '#interrupt-cells' in node %s or bad phandle (referred from interrupt-map[%zu])",
1682 struct node *node)
1684 struct node *root = dti->dt;
1685 struct node *irq_node = NULL, *parent = node;
1689 irq_prop = get_property(node, "interrupts");
1694 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu",
1698 if (parent != node && node_is_interrupt_provider(parent)) {
1731 FAIL(c, dti, node, "Missing interrupt-parent");
1743 FAIL_PROP(c, dti, node, prop,
1759 struct node *node)
1761 struct node *child;
1763 for_each_child(node, child) {
1768 node->bus = &graph_port_bus;
1771 if (!node->parent->bus &&
1772 (streq(node->parent->name, "ports") || get_property(node, "reg")))
1773 node->parent->bus = &graph_ports_bus;
1782 struct node *node)
1785 struct node *child;
1787 if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
1790 for_each_child(node, child) {
1800 if (cnt == 1 && node->addr_cells != -1)
1801 FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
1802 node->children->name);
1807 struct node *node)
1810 const char *unitname = get_unitname(node);
1813 prop = get_property(node, "reg");
1818 FAIL(c, dti, node, "graph node malformed 'reg' property");
1824 FAIL(c, dti, node, "graph node unit address error, expected \"%s\"",
1827 if (node->parent->addr_cells != 1)
1828 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"),
1829 "graph node '#address-cells' is %d, must be 1",
1830 node->parent->addr_cells);
1831 if (node->parent->size_cells != 0)
1832 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"),
1833 "graph node '#size-cells' is %d, must be 0",
1834 node->parent->size_cells);
1838 struct node *node)
1840 if (node->bus != &graph_port_bus)
1843 if (!strprefixeq(node->name, node->basenamelen, "port"))
1844 FAIL(c, dti, node, "graph port node name should be 'port'");
1846 check_graph_reg(c, dti, node);
1850 static struct node *get_remote_endpoint(struct check *c, struct dt_info *dti,
1851 struct node *endpoint)
1854 struct node *node;
1866 node = get_node_by_phandle(dti->dt, phandle);
1867 if (!node)
1870 return node;
1874 struct node *node)
1876 struct node *remote_node;
1878 if (!node->parent || node->parent->bus != &graph_port_bus)
1881 if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
1882 FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'");
1884 check_graph_reg(c, dti, node);
1886 remote_node = get_remote_endpoint(c, dti, node);
1890 if (get_remote_endpoint(c, dti, remote_node) != node)
1891 FAIL(c, dti, node, "graph connection to node '%s' is not bidirectional",