Lines Matching +full:2 +full:nd +full:- +full:cell
1 // SPDX-License-Identifier: GPL-2.0-or-later
12 fprintf(stderr, "=== %s: ", (c)->name); \
71 if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2)))
74 if (prop && prop->srcpos)
75 pos = prop->srcpos;
76 else if (node && node->srcpos)
77 pos = node->srcpos;
83 } else if (streq(dti->outname, "-")) {
86 xasprintf(&str, "%s", dti->outname);
90 (c->error) ? "ERROR" : "Warning", c->name);
94 xasprintf_append(&str, "%s:%s: ", node->fullpath, prop->name);
96 xasprintf_append(&str, "%s: ", node->fullpath);
106 pos = node->srcpos;
107 while (pos->next) {
108 pos = pos->next;
123 (c)->status = FAILED; \
130 (c)->status = FAILED; \
139 TRACE(c, "%s", node->fullpath);
140 if (c->fn)
141 c->fn(c, dti, node);
157 struct node *dt = dti->dt;
161 assert(!c->inprogress);
163 if (c->status != UNCHECKED)
166 c->inprogress = true;
168 for (i = 0; i < c->num_prereqs; i++) {
169 struct check *prq = c->prereq[i];
171 if (prq->status != PASSED) {
172 c->status = PREREQ;
174 c->prereq[i]->name);
178 if (c->status != UNCHECKED)
183 if (c->status == UNCHECKED)
184 c->status = PASSED;
186 TRACE(c, "\tCompleted, status %d", c->status);
189 c->inprogress = false;
190 if ((c->status != PASSED) && (c->error))
211 const char *propname = c->data;
217 if (!data_is_one_string(prop->val))
230 const char *propname = c->data;
237 str = prop->val.val;
238 rem = prop->val.len;
245 rem -= l + 1;
258 const char *propname = c->data;
264 if (prop->val.len != sizeof(cell_t))
265 FAIL_PROP(c, dti, node, prop, "property is not a single cell");
282 for (child2 = child->next_sibling;
284 child2 = child2->next_sibling)
285 if (streq(child->name, child2->name))
296 for (prop2 = prop->next; prop2; prop2 = prop2->next) {
297 if (prop2->deleted)
299 if (streq(prop->name, prop2->name))
309 #define NODECHARS LOWERCASE UPPERCASE DIGITS ",._+-@"
310 #define PROPCHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
311 #define PROPNODECHARSSTRICT LOWERCASE UPPERCASE DIGITS ",-"
316 size_t n = strspn(node->name, c->data);
318 if (n < strlen(node->name))
320 node->name[n]);
327 int n = strspn(node->name, c->data);
329 if (n < node->basenamelen)
331 node->name[n]);
347 if (!node->parent)
350 if (get_property(node->parent, node->name)) {
370 if (prop && !prop->val.len)
390 size_t n = strspn(prop->name, c->data);
392 if (n < strlen(prop->name))
394 prop->name[n]);
406 const char *name = prop->name;
407 size_t n = strspn(name, c->data);
409 if (n == strlen(prop->name))
420 if (name[n] == '#' && ((n == 0) || (name[n-1] == ','))) {
422 n = strspn(name, c->data);
435 ((prop) ? (prop)->name : ""), \
436 ((prop) ? "' in " : ""), (node)->fullpath
442 struct node *dt = dti->dt;
471 for_each_label(node->labels, l)
472 check_duplicate_label(c, dti, l->label, node, NULL, NULL);
475 struct marker *m = prop->val.markers;
477 for_each_label(prop->labels, l)
478 check_duplicate_label(c, dti, l->label, node, prop, NULL);
481 check_duplicate_label(c, dti, m->ref, node, prop, m);
489 struct node *root = dti->dt;
498 if (prop->val.len != sizeof(cell_t)) {
500 prop->val.len, prop->name);
504 m = prop->val.markers;
506 assert(m->offset == 0);
507 if (node != get_node_by_ref(root, m->ref))
512 prop->name);
515 * phandle is allowed - that means allocate a unique
526 phandle, prop->name);
536 struct node *root = dti->dt;
541 assert(!node->phandle);
561 phandle, other->fullpath);
565 node->phandle = phandle;
574 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
575 if (streq((*pp)->name, "name")) {
583 if ((prop->val.len != node->basenamelen + 1U)
584 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
586 " of base node name)", prop->val.val);
590 *pp = prop->next;
591 free(prop->name);
592 data_free(prop->val);
606 struct node *dt = dti->dt;
610 struct marker *m = prop->val.markers;
615 assert(m->offset + sizeof(cell_t) <= prop->val.len);
617 refnode = get_node_by_ref(dt, m->ref);
619 if (!(dti->dtsflags & DTSF_PLUGIN))
620 FAIL(c, dti, node, "Reference to non-existent node or "
621 "label \"%s\"\n", m->ref);
623 *((fdt32_t *)(prop->val.val + m->offset)) =
629 *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
641 struct node *dt = dti->dt;
645 struct marker *m = prop->val.markers;
650 assert(m->offset <= prop->val.len);
652 refnode = get_node_by_ref(dt, m->ref);
654 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n",
655 m->ref);
659 path = refnode->fullpath;
660 prop->val = data_insert_at_marker(prop->val, m, path,
672 if (generate_symbols && node->labels)
674 if (node->omit_if_unused && !node->is_referenced)
682 WARNING_IF_NOT_CELL(address_cells_is_cell, "#address-cells");
683 WARNING_IF_NOT_CELL(size_cells_is_cell, "#size-cells");
698 if (!strends(prop->name, "-names"))
701 c->data = prop->name;
712 if (!streq(node->name, "aliases"))
716 if (streq(prop->name, "phandle")
717 || streq(prop->name, "linux,phandle")) {
721 if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) {
723 prop->val.val);
726 if (strspn(prop->name, LOWERCASE DIGITS "-") != strlen(prop->name))
727 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'");
737 node->addr_cells = -1;
738 node->size_cells = -1;
740 prop = get_property(node, "#address-cells");
742 node->addr_cells = propval_cell(prop);
744 prop = get_property(node, "#size-cells");
746 node->size_cells = propval_cell(prop);
752 (((n)->addr_cells == -1) ? 2 : (n)->addr_cells)
754 (((n)->size_cells == -1) ? 1 : (n)->size_cells)
766 if (!node->parent) {
771 if (prop->val.len == 0)
774 addr_cells = node_addr_cells(node->parent);
775 size_cells = node_size_cells(node->parent);
778 if (!is_multiple_of(prop->val.len, entrylen))
780 "(#address-cells == %d, #size-cells == %d)",
781 prop->val.len, addr_cells, size_cells);
790 const char *ranges = c->data;
796 if (!node->parent) {
802 p_addr_cells = node_addr_cells(node->parent);
803 p_size_cells = node_size_cells(node->parent);
808 if (prop->val.len == 0) {
811 "#address-cells (%d) differs from %s (%d)",
812 ranges, c_addr_cells, node->parent->fullpath,
816 "#size-cells (%d) differs from %s (%d)",
817 ranges, c_size_cells, node->parent->fullpath,
819 } else if (!is_multiple_of(prop->val.len, entrylen)) {
821 "(parent #address-cells == %d, child #address-cells == %d, "
822 "#size-cells == %d)", ranges, prop->val.len,
827 WARNING(dma_ranges_format, check_ranges_format, "dma-ranges", &addr_size_cells);
839 if (!prop || !streq(prop->val.val, "pci"))
842 node->bus = &pci_bus;
844 if (!strprefixeq(node->name, node->basenamelen, "pci") &&
845 !strprefixeq(node->name, node->basenamelen, "pcie"))
853 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge");
854 if (node_size_cells(node) != 2)
855 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge");
857 prop = get_property(node, "bus-range");
861 if (prop->val.len != (sizeof(cell_t) * 2)) {
862 FAIL_PROP(c, dti, node, prop, "value must be 2 cells");
865 cells = (cell_t *)prop->val.val;
867 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell");
880 if (!node->parent || (node->parent->bus != &pci_bus))
887 cells = (cell_t *)prop->val.val;
890 prop = get_property(node->parent, "bus-range");
894 cells = (cell_t *)prop->val.val;
899 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)",
912 if (!node->parent || (node->parent->bus != &pci_bus))
919 cells = (cell_t *)prop->val.val;
920 if (cells[1] || cells[2])
921 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0");
948 .name = "simple-bus",
960 for (str = prop->val.val, end = str + prop->val.len; str < end;
961 str += strnlen(str, end - str) + 1) {
970 if (node_is_compatible(node, "simple-bus"))
971 node->bus = &simple_bus;
985 if (!node->parent || (node->parent->bus != &simple_bus))
990 cells = (cell_t *)prop->val.val;
993 if (prop && prop->val.len)
995 cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
999 if (node->parent->parent && !(node->bus == &simple_bus))
1004 size = node_addr_cells(node->parent);
1005 while (size--)
1010 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"",
1016 .name = "i2c-bus",
1021 if (strprefixeq(node->name, node->basenamelen, "i2c-bus") ||
1022 strprefixeq(node->name, node->basenamelen, "i2c-arb")) {
1023 node->bus = &i2c_bus;
1024 } else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
1027 if (strprefixeq(child->name, child->basenamelen, "i2c-bus"))
1030 node->bus = &i2c_bus;
1034 if (!node->children)
1038 FAIL(c, dti, node, "incorrect #address-cells for I2C bus");
1040 FAIL(c, dti, node, "incorrect #size-cells for I2C bus");
1057 if (!node->parent || (node->parent->bus != &i2c_bus))
1062 cells = (cell_t *)prop->val.val;
1077 for (len = prop->val.len; len > 0; len -= 4) {
1084 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
1087 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",
1094 .name = "spi-bus",
1101 if (strprefixeq(node->name, node->basenamelen, "spi")) {
1102 node->bus = &spi_bus;
1113 if (strstarts(prop->name, "spi-")) {
1114 node->bus = &spi_bus;
1118 if (node->bus == &spi_bus)
1122 if (node->bus == &spi_bus && get_property(node, "reg"))
1125 if (node->bus != &spi_bus || !node->children)
1128 if (get_property(node, "spi-slave"))
1131 FAIL(c, dti, node, "incorrect #address-cells for SPI bus");
1133 FAIL(c, dti, node, "incorrect #size-cells for SPI bus");
1146 if (!node->parent || (node->parent->bus != &spi_bus))
1149 if (get_property(node->parent, "spi-slave"))
1154 cells = (cell_t *)prop->val.val;
1174 if (node->parent && node->parent->bus)
1180 if (!strncmp(unitname, "0x", 2)) {
1183 unitname += 2;
1199 if (!node->parent)
1208 if (node->parent->addr_cells == -1)
1209 FAIL(c, dti, node, "Relying on default #address-cells value");
1211 if (node->parent->size_cells == -1)
1212 FAIL(c, dti, node, "Relying on default #size-cells value");
1222 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
1225 if (get_property(node, "ranges") || get_property(node, "dma-ranges") || !node->children)
1234 * child nodes then make #address-cells/#size-cells necessary:
1240 FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" or \"ranges\" property");
1250 char *str = prop->val.val;
1265 if (node->addr_cells < 0 || node->size_cells < 0)
1268 if (!node->children)
1290 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
1314 struct node *dt = dti->dt;
1326 prop = get_property(chosen, "interrupt-controller");
1329 "/chosen has obsolete \"interrupt-controller\" property");
1337 if (!streq(node->name, "chosen"))
1340 if (node->parent != dti->dt)
1350 if (!streq(node->name, "chosen"))
1357 c->data = prop->name;
1367 if (!streq(node->name, "chosen"))
1370 prop = get_property(node, "stdout-path");
1372 prop = get_property(node, "linux,stdout-path");
1375 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead");
1378 c->data = prop->name;
1395 struct node *root = dti->dt;
1396 unsigned int cell, cellsize = 0;
1398 if (!is_multiple_of(prop->val.len, sizeof(cell_t))) {
1401 prop->val.len, sizeof(cell_t));
1405 for (cell = 0; cell < prop->val.len / sizeof(cell_t); cell += cellsize + 1) {
1411 phandle = propval_cell_n(prop, cell);
1413 * Some bindings use a cell value 0 or -1 to skip over optional
1418 if (dti->dtsflags & DTSF_PLUGIN)
1425 /* If we have markers, verify the current cell is a phandle */
1426 if (prop->val.markers) {
1427 struct marker *m = prop->val.markers;
1429 if (m->offset == (cell * sizeof(cell_t)))
1434 "cell %d is not a phandle reference",
1435 cell);
1441 "Could not get phandle node for (cell %d)",
1442 cell);
1446 cellprop = get_property(provider_node, provider->cell_name);
1449 } else if (provider->optional) {
1453 provider->cell_name,
1454 provider_node->fullpath,
1455 prop->name, cell);
1459 expected = (cell + cellsize + 1) * sizeof(cell_t);
1460 if ((expected <= cell) || prop->val.len < expected) {
1462 "property size (%d) too small for cell size %u",
1463 prop->val.len, cellsize);
1473 const struct provider *provider = c->data;
1476 prop = get_property(node, provider->prop_name);
1487 WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells");
1488 WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells");
1489 WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells");
1490 WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells");
1491 WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells");
1492 WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells");
1493 WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells");
1494 WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells");
1495 WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true);
1496 WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells");
1497 WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells");
1498 WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
1499 WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
1500 WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
1501 WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells");
1502 WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
1507 * *-gpios and *-gpio can appear in property names,
1510 if (strends(prop->name, ",nr-gpios"))
1513 return strends(prop->name, "-gpios") ||
1514 streq(prop->name, "gpios") ||
1515 strends(prop->name, "-gpio") ||
1516 streq(prop->name, "gpio");
1526 if (get_property(node, "gpio-hog"))
1535 provider.prop_name = prop->name;
1536 provider.cell_name = "#gpio-cells";
1554 if (!strends(prop->name, "gpio"))
1558 "'[*-]gpio' is deprecated, use '[*-]gpios' instead");
1568 prop = get_property(node, "interrupt-controller");
1572 prop = get_property(node, "interrupt-map");
1586 prop = get_property(node, "#interrupt-cells");
1589 "Missing '#interrupt-cells' in interrupt provider");
1595 "'#interrupt-cells' found, but node is not an interrupt provider");
1605 struct node *root = dti->dt;
1607 size_t cellsize, cell, map_cells;
1609 irq_map_prop = get_property(node, "interrupt-map");
1613 if (node->addr_cells < 0) {
1615 "Missing '#address-cells' in interrupt-map provider");
1619 cellsize += propval_cell(get_property(node, "#interrupt-cells"));
1621 prop = get_property(node, "interrupt-map-mask");
1622 if (prop && (prop->val.len != (cellsize * sizeof(cell_t))))
1625 prop->val.len, cellsize * sizeof(cell_t));
1627 if (!is_multiple_of(irq_map_prop->val.len, sizeof(cell_t))) {
1630 irq_map_prop->val.len, sizeof(cell_t));
1634 map_cells = irq_map_prop->val.len / sizeof(cell_t);
1635 for (cell = 0; cell < map_cells; ) {
1641 if ((cell + cellsize) >= map_cells) {
1644 irq_map_prop->val.len, (cell + cellsize) * sizeof(cell_t));
1647 cell += cellsize;
1649 phandle = propval_cell_n(irq_map_prop, cell);
1652 if (!(dti->dtsflags & DTSF_PLUGIN))
1654 "Cell %zu is not a phandle(%d)",
1655 cell, phandle);
1662 "Could not get phandle(%d) node for (cell %zu)",
1663 phandle, cell);
1667 cellprop = get_property(provider_node, "#interrupt-cells");
1671 FAIL(c, dti, node, "Missing property '#interrupt-cells' in node %s or bad phandle (referred from interrupt-map[%zu])",
1672 provider_node->fullpath, cell);
1676 cellprop = get_property(provider_node, "#address-cells");
1681 "Missing property '#address-cells' in node %s, using 0 as fallback",
1682 provider_node->fullpath);
1684 cell += 1 + parent_cellsize;
1685 if (cell > map_cells)
1688 irq_map_prop->val.len, cell * sizeof(cell_t));
1697 struct node *root = dti->dt;
1706 if (!is_multiple_of(irq_prop->val.len, sizeof(cell_t)))
1708 irq_prop->val.len, sizeof(cell_t));
1716 prop = get_property(parent, "interrupt-parent");
1722 if (dti->dtsflags & DTSF_PLUGIN)
1735 "Missing interrupt-controller or interrupt-map property");
1740 parent = parent->parent;
1744 FAIL(c, dti, node, "Missing interrupt-parent");
1748 prop = get_property(irq_node, "#interrupt-cells");
1755 if (!is_multiple_of(irq_prop->val.len, irq_cells * sizeof(cell_t))) {
1758 irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)));
1764 .name = "graph-port",
1768 .name = "graph-ports",
1777 if (!(strprefixeq(child->name, child->basenamelen, "endpoint") ||
1778 get_property(child, "remote-endpoint")))
1782 if (!node->parent) {
1783 FAIL(c, dti, node, "root node contains endpoint node '%s', potentially misplaced remote-endpoint property", child->name);
1786 node->bus = &graph_port_bus;
1789 if (!node->parent->bus &&
1790 (streq(node->parent->name, "ports") || get_property(node, "reg")))
1791 node->parent->bus = &graph_ports_bus;
1810 if (!(prop->val.val && prop->val.len == sizeof(cell_t))) {
1820 if (node->parent->addr_cells != 1)
1821 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"),
1822 "graph node '#address-cells' is %d, must be 1",
1823 node->parent->addr_cells);
1824 if (node->parent->size_cells != 0)
1825 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"),
1826 "graph node '#size-cells' is %d, must be 0",
1827 node->parent->size_cells);
1833 if (node->bus != &graph_port_bus)
1839 if (dti->dtsflags & DTSF_PLUGIN)
1842 if (!strprefixeq(node->name, node->basenamelen, "port"))
1854 prop = get_property(endpoint, "remote-endpoint");
1863 node = get_node_by_phandle(dti->dt, phandle);
1875 if (!node->parent || node->parent->bus != &graph_port_bus)
1881 if (dti->dtsflags & DTSF_PLUGIN)
1884 if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
1893 remote_node->fullpath);
1903 if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
1909 /* No error if we have any non-zero unit address */
1916 if (cnt == 1 && node->addr_cells != -1)
1917 FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
1918 node->children->name);
2018 if ((warn && !c->warn) || (error && !c->error))
2019 for (i = 0; i < c->num_prereqs; i++)
2020 enable_warning_error(c->prereq[i], warn, error);
2022 c->warn = c->warn || warn;
2023 c->error = c->error || error;
2032 if ((warn && c->warn) || (error && c->error)) {
2037 for (j = 0; j < cc->num_prereqs; j++)
2038 if (cc->prereq[j] == c)
2043 c->warn = c->warn && !warn;
2044 c->error = c->error && !error;
2053 if ((strncmp(arg, "no-", 3) == 0)
2062 if (streq(c->name, name)) {
2082 if (c->warn || c->error)
2089 "(use -f to force output)\n");
2090 exit(2);