summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2017-12-14 16:40:01 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2017-12-15 13:26:57 +1100
commitc81d389a10ccf4a2af7e170aa216f38ca3ad1961 (patch)
tree71fe02600b5e49928f636723ec7717df5fa2bac7
parente671852042a77b15ec72ca908291c7d647e4fb01 (diff)
downloaddevice-tree-compiler-c81d389a10ccf4a2af7e170aa216f38ca3ad1961.tar.gz
checks: add chosen node checks
Add some checks for /chosen node. These check that chosen is located at the root level and that bootargs and stdout-path properties are strings. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--checks.c51
-rw-r--r--tests/bad-chosen.dts10
-rwxr-xr-xtests/run_tests.sh3
3 files changed, 64 insertions, 0 deletions
diff --git a/checks.c b/checks.c
index 66e5fd6..1cded36 100644
--- a/checks.c
+++ b/checks.c
@@ -1052,6 +1052,56 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
WARNING(obsolete_chosen_interrupt_controller,
check_obsolete_chosen_interrupt_controller, NULL);
+static void check_chosen_node_is_root(struct check *c, struct dt_info *dti,
+ struct node *node)
+{
+ if (!streq(node->name, "chosen"))
+ return;
+
+ if (node->parent != dti->dt)
+ FAIL(c, dti, "chosen node '%s' must be at root node",
+ node->fullpath);
+}
+WARNING(chosen_node_is_root, check_chosen_node_is_root, NULL);
+
+static void check_chosen_node_bootargs(struct check *c, struct dt_info *dti,
+ struct node *node)
+{
+ struct property *prop;
+
+ if (!streq(node->name, "chosen"))
+ return;
+
+ prop = get_property(node, "bootargs");
+ if (!prop)
+ return;
+
+ c->data = prop->name;
+ check_is_string(c, dti, node);
+}
+WARNING(chosen_node_bootargs, check_chosen_node_bootargs, NULL);
+
+static void check_chosen_node_stdout_path(struct check *c, struct dt_info *dti,
+ struct node *node)
+{
+ struct property *prop;
+
+ if (!streq(node->name, "chosen"))
+ return;
+
+ prop = get_property(node, "stdout-path");
+ if (!prop) {
+ prop = get_property(node, "linux,stdout-path");
+ if (!prop)
+ return;
+ FAIL(c, dti, "Use 'stdout-path' instead of 'linux,stdout-path'");
+ }
+
+ c->data = prop->name;
+ check_is_string(c, dti, node);
+}
+WARNING(chosen_node_stdout_path, check_chosen_node_stdout_path, NULL);
+
struct provider {
const char *prop_name;
const char *cell_name;
@@ -1354,6 +1404,7 @@ static struct check *check_table[] = {
&avoid_default_addr_size,
&avoid_unnecessary_addr_size,
&obsolete_chosen_interrupt_controller,
+ &chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path,
&clocks_property,
&cooling_device_property,
diff --git a/tests/bad-chosen.dts b/tests/bad-chosen.dts
new file mode 100644
index 0000000..d6f53c6
--- /dev/null
+++ b/tests/bad-chosen.dts
@@ -0,0 +1,10 @@
+/dts-v1/;
+
+/ {
+ node2 {
+ chosen {
+ bootargs = <0xdeadbeef>;
+ stdout-path = <1>;
+ };
+ };
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index d36dffb..61c95f1 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -547,6 +547,9 @@ dtc_tests () {
check_tests bad-ncells.dts address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell
check_tests bad-string-props.dts device_type_is_string model_is_string status_is_string label_is_string compatible_is_string_list names_is_string_list
+ check_tests bad-chosen.dts chosen_node_is_root
+ check_tests bad-chosen.dts chosen_node_bootargs
+ check_tests bad-chosen.dts chosen_node_stdout_path
check_tests bad-reg-ranges.dts reg_format ranges_format
check_tests bad-empty-ranges.dts ranges_format
check_tests reg-ranges-root.dts reg_format ranges_format