According to the DT Spec (and ePAPR), node and property names should be 1-31 characters. Signed-off-by: Rob Herring <robh@xxxxxxxxxx> --- Surprisingly, there aren't just a ton of warnings introduced with this. I'm not really sure where the 31 character limit came from. Maybe it should be increased rather than trying to fix any long names. Either way, we should have a check if there's a spec'ed limit. Rob checks.c | 23 ++++++++++++++++++++++- tests/bad_node_name_length.dts | 6 ++++++ tests/bad_prop_name_length.dts | 5 +++++ tests/run_tests.sh | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/bad_node_name_length.dts create mode 100644 tests/bad_prop_name_length.dts diff --git a/checks.c b/checks.c index a2cc1036c915..7f049369e4b0 100644 --- a/checks.c +++ b/checks.c @@ -303,6 +303,14 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, } CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT); +static void check_node_name_length(struct check *c, struct dt_info *dti, + struct node *node) +{ + if (node->basenamelen > 31) + FAIL(c, dti, node, "node name exceeds maximum length of 31 chars"); +} +WARNING(node_name_length, check_node_name_length, NULL); + static void check_node_name_format(struct check *c, struct dt_info *dti, struct node *node) { @@ -385,6 +393,18 @@ static void check_property_name_chars_strict(struct check *c, } CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); +static void check_property_name_length(struct check *c, struct dt_info *dti, + struct node *node) +{ + struct property *prop; + + for_each_property(node, prop) { + if (strlen(prop->name) > 31) + FAIL_PROP(c, dti, node, prop, "property name exceeds maximum length of 31 chars"); + } +} +WARNING(property_name_length, check_property_name_length, NULL); + #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ ((mark) ? "value of " : ""), \ @@ -1552,7 +1572,8 @@ WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes); static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, - &node_name_chars, &node_name_format, &property_name_chars, + &node_name_chars, &node_name_format, &node_name_length, + &property_name_chars, &property_name_length, &name_is_string, &name_properties, &duplicate_label, diff --git a/tests/bad_node_name_length.dts b/tests/bad_node_name_length.dts new file mode 100644 index 000000000000..a40da4cf686c --- /dev/null +++ b/tests/bad_node_name_length.dts @@ -0,0 +1,6 @@ +/dts-v1/; + +/ { + a-node-with-more-than-31-charsXX@1 { + }; +}; diff --git a/tests/bad_prop_name_length.dts b/tests/bad_prop_name_length.dts new file mode 100644 index 000000000000..1709448c4e2d --- /dev/null +++ b/tests/bad_prop_name_length.dts @@ -0,0 +1,5 @@ +/dts-v1/; + +/ { + a-prop-with-more-than-31-charsXX; +}; diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 76eafb431197..33882d1fd0d5 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -628,6 +628,8 @@ dtc_tests () { run_sh_test dtc-checkfails.sh node_name_chars -- -I dtb -O dtb bad_node_char.dtb run_sh_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb run_sh_test dtc-checkfails.sh property_name_chars -- -I dtb -O dtb bad_prop_char.dtb + check_tests bad_node_name_length.dts node_name_length + check_tests bad_prop_name_length.dts property_name_length run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label1.dts run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label2.dts -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html