Lines Matching refs:c
10 #define TRACE(c, ...) \ argument
12 fprintf(stderr, "=== %s: ", (c)->name); \
17 #define TRACE(c, fmt, ...) do { } while (0) argument
29 typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node);
61 static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti, in check_msg() argument
71 if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2))) in check_msg()
90 (c->error) ? "ERROR" : "Warning", c->name); in check_msg()
119 #define FAIL(c, dti, node, ...) \ argument
121 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
122 (c)->status = FAILED; \
123 check_msg((c), dti, node, NULL, __VA_ARGS__); \
126 #define FAIL_PROP(c, dti, node, prop, ...) \ argument
128 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
129 (c)->status = FAILED; \
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) in check_nodes_props() argument
138 TRACE(c, "%s", node->fullpath); in check_nodes_props()
139 if (c->fn) in check_nodes_props()
140 c->fn(c, dti, node); in check_nodes_props()
143 check_nodes_props(c, dti, child); in check_nodes_props()
146 static bool run_check(struct check *c, struct dt_info *dti) in run_check() argument
152 assert(!c->inprogress); in run_check()
154 if (c->status != UNCHECKED) in run_check()
157 c->inprogress = true; in run_check()
159 for (i = 0; i < c->num_prereqs; i++) { in run_check()
160 struct check *prq = c->prereq[i]; in run_check()
163 c->status = PREREQ; in run_check()
164 check_msg(c, dti, NULL, NULL, "Failed prerequisite '%s'", in run_check()
165 c->prereq[i]->name); in run_check()
169 if (c->status != UNCHECKED) in run_check()
172 check_nodes_props(c, dti, dt); in run_check()
174 if (c->status == UNCHECKED) in run_check()
175 c->status = PASSED; in run_check()
177 TRACE(c, "\tCompleted, status %d", c->status); in run_check()
180 c->inprogress = false; in run_check()
181 if ((c->status != PASSED) && (c->error)) in run_check()
191 static inline void check_always_fail(struct check *c, struct dt_info *dti, in check_always_fail() argument
194 FAIL(c, dti, node, "always_fail check"); in check_always_fail()
198 static void check_is_string(struct check *c, struct dt_info *dti, in check_is_string() argument
202 char *propname = c->data; in check_is_string()
209 FAIL_PROP(c, dti, node, prop, "property is not a string"); in check_is_string()
216 static void check_is_string_list(struct check *c, struct dt_info *dti, in check_is_string_list() argument
221 char *propname = c->data; in check_is_string_list()
233 FAIL_PROP(c, dti, node, prop, "property is not a string list"); in check_is_string_list()
245 static void check_is_cell(struct check *c, struct dt_info *dti, in check_is_cell() argument
249 char *propname = c->data; in check_is_cell()
256 FAIL_PROP(c, dti, node, prop, "property is not a single cell"); in check_is_cell()
267 static void check_duplicate_node_names(struct check *c, struct dt_info *dti, in check_duplicate_node_names() argument
277 FAIL(c, dti, child2, "Duplicate node name"); in check_duplicate_node_names()
281 static void check_duplicate_property_names(struct check *c, struct dt_info *dti, in check_duplicate_property_names() argument
291 FAIL_PROP(c, dti, node, prop, "Duplicate property name"); in check_duplicate_property_names()
303 static void check_node_name_chars(struct check *c, struct dt_info *dti, in check_node_name_chars() argument
306 int n = strspn(node->name, c->data); in check_node_name_chars()
309 FAIL(c, dti, node, "Bad character '%c' in node name", in check_node_name_chars()
314 static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, in check_node_name_chars_strict() argument
317 int n = strspn(node->name, c->data); in check_node_name_chars_strict()
320 FAIL(c, dti, node, "Character '%c' not recommended in node name", in check_node_name_chars_strict()
325 static void check_node_name_format(struct check *c, struct dt_info *dti, in check_node_name_format() argument
329 FAIL(c, dti, node, "multiple '@' characters in node name"); in check_node_name_format()
333 static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, in check_unit_address_vs_reg() argument
352 FAIL(c, dti, node, "node has a reg or ranges property, but no unit name"); in check_unit_address_vs_reg()
355 FAIL(c, dti, node, "node has a unit name, but no reg or ranges property"); in check_unit_address_vs_reg()
360 static void check_property_name_chars(struct check *c, struct dt_info *dti, in check_property_name_chars() argument
366 int n = strspn(prop->name, c->data); in check_property_name_chars()
369 FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name", in check_property_name_chars()
375 static void check_property_name_chars_strict(struct check *c, in check_property_name_chars_strict() argument
383 int n = strspn(name, c->data); in check_property_name_chars_strict()
398 n = strspn(name, c->data); in check_property_name_chars_strict()
401 FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name", in check_property_name_chars_strict()
414 static void check_duplicate_label(struct check *c, struct dt_info *dti, in check_duplicate_label() argument
435 FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT in check_duplicate_label()
441 static void check_duplicate_label_node(struct check *c, struct dt_info *dti, in check_duplicate_label_node() argument
448 check_duplicate_label(c, dti, l->label, node, NULL, NULL); in check_duplicate_label_node()
454 check_duplicate_label(c, dti, l->label, node, prop, NULL); in check_duplicate_label_node()
457 check_duplicate_label(c, dti, m->ref, node, prop, m); in check_duplicate_label_node()
462 static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, in check_phandle_prop() argument
475 FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property", in check_phandle_prop()
487 FAIL(c, dti, node, "%s is a reference to another node", in check_phandle_prop()
501 FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property", in check_phandle_prop()
509 static void check_explicit_phandles(struct check *c, struct dt_info *dti, in check_explicit_phandles() argument
519 phandle = check_phandle_prop(c, dti, node, "phandle"); in check_explicit_phandles()
521 linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle"); in check_explicit_phandles()
528 FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'" in check_explicit_phandles()
536 FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)", in check_explicit_phandles()
545 static void check_name_properties(struct check *c, struct dt_info *dti, in check_name_properties() argument
561 FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead" in check_name_properties()
579 static void fixup_phandle_references(struct check *c, struct dt_info *dti, in fixup_phandle_references() argument
596 FAIL(c, dti, node, "Reference to non-existent node or " in fixup_phandle_references()
614 static void fixup_path_references(struct check *c, struct dt_info *dti, in fixup_path_references() argument
630 FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n", in fixup_path_references()
645 static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti, in fixup_omit_unused_nodes() argument
669 static void check_names_is_string_list(struct check *c, struct dt_info *dti, in check_names_is_string_list() argument
679 c->data = prop->name; in check_names_is_string_list()
680 check_is_string_list(c, dti, node); in check_names_is_string_list()
685 static void check_alias_paths(struct check *c, struct dt_info *dti, in check_alias_paths() argument
700 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)", in check_alias_paths()
705 FAIL(c, dti, node, "aliases property name must include only lowercase and '-'"); in check_alias_paths()
710 static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, in fixup_addr_size_cells() argument
734 static void check_reg_format(struct check *c, struct dt_info *dti, in check_reg_format() argument
745 FAIL(c, dti, node, "Root node has a \"reg\" property"); in check_reg_format()
750 FAIL_PROP(c, dti, node, prop, "property is empty"); in check_reg_format()
757 FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) " in check_reg_format()
763 static void check_ranges_format(struct check *c, struct dt_info *dti, in check_ranges_format() argument
768 const char *ranges = c->data; in check_ranges_format()
775 FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property", in check_ranges_format()
788 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its " in check_ranges_format()
793 FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its " in check_ranges_format()
798 FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) " in check_ranges_format()
811 static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_pci_bridge() argument
824 FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\""); in check_pci_bridge()
828 FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)"); in check_pci_bridge()
831 FAIL(c, dti, node, "incorrect #address-cells for PCI bridge"); in check_pci_bridge()
833 FAIL(c, dti, node, "incorrect #size-cells for PCI bridge"); in check_pci_bridge()
840 FAIL_PROP(c, dti, node, prop, "value must be 2 cells"); in check_pci_bridge()
845 FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell"); in check_pci_bridge()
847 FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256"); in check_pci_bridge()
852 static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node) in check_pci_device_bus_num() argument
877 FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)", in check_pci_device_bus_num()
882 static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node) in check_pci_device_reg() argument
899 FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0"); in check_pci_device_reg()
906 FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space"); in check_pci_device_reg()
908 FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0"); in check_pci_device_reg()
920 FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"", in check_pci_device_reg()
946 static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_simple_bus_bridge() argument
954 static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node) in check_simple_bus_reg() argument
978 FAIL(c, dti, node, "missing or empty reg/ranges property"); in check_simple_bus_reg()
988 FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"", in check_simple_bus_reg()
997 static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_i2c_bus_bridge() argument
1016 FAIL(c, dti, node, "incorrect #address-cells for I2C bus"); in check_i2c_bus_bridge()
1018 FAIL(c, dti, node, "incorrect #size-cells for I2C bus"); in check_i2c_bus_bridge()
1026 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node) in check_i2c_bus_reg() argument
1043 FAIL(c, dti, node, "missing or empty reg property"); in check_i2c_bus_reg()
1052 FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"", in check_i2c_bus_reg()
1061 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", in check_i2c_bus_reg()
1064 …FAIL_PROP(c, dti, node, prop, "I2C address must be less than 7-bits, got \"0x%x\". Set I2C_TEN_BIT… in check_i2c_bus_reg()
1074 static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) in check_spi_bus_bridge() argument
1100 FAIL(c, dti, node, "node name for SPI buses should be 'spi'"); in check_spi_bus_bridge()
1108 FAIL(c, dti, node, "incorrect #address-cells for SPI bus"); in check_spi_bus_bridge()
1110 FAIL(c, dti, node, "incorrect #size-cells for SPI bus"); in check_spi_bus_bridge()
1115 static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node) in check_spi_bus_reg() argument
1134 FAIL(c, dti, node, "missing or empty reg property"); in check_spi_bus_reg()
1141 FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"", in check_spi_bus_reg()
1146 static void check_unit_address_format(struct check *c, struct dt_info *dti, in check_unit_address_format() argument
1158 FAIL(c, dti, node, "unit name should not have leading \"0x\""); in check_unit_address_format()
1163 FAIL(c, dti, node, "unit name should not have leading 0s"); in check_unit_address_format()
1171 static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti, in check_avoid_default_addr_size() argument
1186 FAIL(c, dti, node, "Relying on default #address-cells value"); in check_avoid_default_addr_size()
1189 FAIL(c, dti, node, "Relying on default #size-cells value"); in check_avoid_default_addr_size()
1194 static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *dti, in check_avoid_unnecessary_addr_size() argument
1214 …FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" pro… in check_avoid_unnecessary_addr_size()
1232 static void check_unique_unit_address_common(struct check *c, in check_unique_unit_address_common() argument
1264 FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath); in check_unique_unit_address_common()
1269 static void check_unique_unit_address(struct check *c, struct dt_info *dti, in check_unique_unit_address() argument
1272 check_unique_unit_address_common(c, dti, node, false); in check_unique_unit_address()
1276 static void check_unique_unit_address_if_enabled(struct check *c, struct dt_info *dti, in check_unique_unit_address_if_enabled() argument
1279 check_unique_unit_address_common(c, dti, node, true); in check_unique_unit_address_if_enabled()
1284 static void check_obsolete_chosen_interrupt_controller(struct check *c, in check_obsolete_chosen_interrupt_controller() argument
1302 FAIL_PROP(c, dti, node, prop, in check_obsolete_chosen_interrupt_controller()
1308 static void check_chosen_node_is_root(struct check *c, struct dt_info *dti, in check_chosen_node_is_root() argument
1315 FAIL(c, dti, node, "chosen node must be at root node"); in check_chosen_node_is_root()
1319 static void check_chosen_node_bootargs(struct check *c, struct dt_info *dti, in check_chosen_node_bootargs() argument
1331 c->data = prop->name; in check_chosen_node_bootargs()
1332 check_is_string(c, dti, node); in check_chosen_node_bootargs()
1336 static void check_chosen_node_stdout_path(struct check *c, struct dt_info *dti, in check_chosen_node_stdout_path() argument
1349 FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead"); in check_chosen_node_stdout_path()
1352 c->data = prop->name; in check_chosen_node_stdout_path()
1353 check_is_string(c, dti, node); in check_chosen_node_stdout_path()
1363 static void check_property_phandle_args(struct check *c, in check_property_phandle_args() argument
1373 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1406 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1413 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1425 FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])", in check_property_phandle_args()
1433 FAIL_PROP(c, dti, node, prop, in check_property_phandle_args()
1440 static void check_provider_cells_property(struct check *c, in check_provider_cells_property() argument
1444 struct provider *provider = c->data; in check_provider_cells_property()
1451 check_property_phandle_args(c, dti, node, prop, provider); in check_provider_cells_property()
1496 static void check_gpios_property(struct check *c, in check_gpios_property() argument
1515 check_property_phandle_args(c, dti, node, prop, &provider); in check_gpios_property()
1521 static void check_deprecated_gpio_property(struct check *c, in check_deprecated_gpio_property() argument
1537 FAIL_PROP(c, dti, node, prop, in check_deprecated_gpio_property()
1559 static void check_interrupt_provider(struct check *c, in check_interrupt_provider() argument
1570 FAIL(c, dti, node, in check_interrupt_provider()
1575 FAIL(c, dti, node, in check_interrupt_provider()
1580 static void check_interrupts_property(struct check *c, in check_interrupts_property() argument
1594 FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu", in check_interrupts_property()
1611 FAIL_PROP(c, dti, parent, prop, "Invalid phandle"); in check_interrupts_property()
1617 FAIL_PROP(c, dti, parent, prop, "Bad phandle"); in check_interrupts_property()
1621 FAIL(c, dti, irq_node, in check_interrupts_property()
1631 FAIL(c, dti, node, "Missing interrupt-parent"); in check_interrupts_property()
1643 FAIL_PROP(c, dti, node, prop, in check_interrupts_property()
1658 static void check_graph_nodes(struct check *c, struct dt_info *dti, in check_graph_nodes() argument
1681 static void check_graph_child_address(struct check *c, struct dt_info *dti, in check_graph_child_address() argument
1701 …FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not nece… in check_graph_child_address()
1706 static void check_graph_reg(struct check *c, struct dt_info *dti, in check_graph_reg() argument
1718 FAIL(c, dti, node, "graph node malformed 'reg' property"); in check_graph_reg()
1724 FAIL(c, dti, node, "graph node unit address error, expected \"%s\"", in check_graph_reg()
1728 FAIL_PROP(c, dti, node, get_property(node, "#address-cells"), in check_graph_reg()
1732 FAIL_PROP(c, dti, node, get_property(node, "#size-cells"), in check_graph_reg()
1737 static void check_graph_port(struct check *c, struct dt_info *dti, in check_graph_port() argument
1744 FAIL(c, dti, node, "graph port node name should be 'port'"); in check_graph_port()
1746 check_graph_reg(c, dti, node); in check_graph_port()
1750 static struct node *get_remote_endpoint(struct check *c, struct dt_info *dti, in get_remote_endpoint() argument
1768 FAIL_PROP(c, dti, endpoint, prop, "graph phandle is not valid"); in get_remote_endpoint()
1773 static void check_graph_endpoint(struct check *c, struct dt_info *dti, in check_graph_endpoint() argument
1782 FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'"); in check_graph_endpoint()
1784 check_graph_reg(c, dti, node); in check_graph_endpoint()
1786 remote_node = get_remote_endpoint(c, dti, node); in check_graph_endpoint()
1790 if (get_remote_endpoint(c, dti, remote_node) != node) in check_graph_endpoint()
1791 FAIL(c, dti, node, "graph connection to node '%s' is not bidirectional", in check_graph_endpoint()
1870 static void enable_warning_error(struct check *c, bool warn, bool error) in enable_warning_error() argument
1875 if ((warn && !c->warn) || (error && !c->error)) in enable_warning_error()
1876 for (i = 0; i < c->num_prereqs; i++) in enable_warning_error()
1877 enable_warning_error(c->prereq[i], warn, error); in enable_warning_error()
1879 c->warn = c->warn || warn; in enable_warning_error()
1880 c->error = c->error || error; in enable_warning_error()
1883 static void disable_warning_error(struct check *c, bool warn, bool error) in disable_warning_error() argument
1889 if ((warn && c->warn) || (error && c->error)) { in disable_warning_error()
1895 if (cc->prereq[j] == c) in disable_warning_error()
1900 c->warn = c->warn && !warn; in disable_warning_error()
1901 c->error = c->error && !error; in disable_warning_error()
1917 struct check *c = check_table[i]; in parse_checks_option() local
1919 if (streq(c->name, name)) { in parse_checks_option()
1921 enable_warning_error(c, warn, error); in parse_checks_option()
1923 disable_warning_error(c, warn, error); in parse_checks_option()
1937 struct check *c = check_table[i]; in process_checks() local
1939 if (c->warn || c->error) in process_checks()
1940 error = error || run_check(c, dti); in process_checks()