[Crosstoolchain-logs] [device-tree-compiler] 03/57: checks: Warn on node name unit-addresses with '0x' or leading 0s
Vagrant Cascadian
vagrant at moszumanska.debian.org
Thu Sep 28 22:03:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
vagrant pushed a commit to branch upstream/latest
in repository device-tree-compiler.
commit cdbb2b6c7a3a5aabf6f942f1b5f5b1d997555b07
Author: Rob Herring <robh at kernel.org>
Date: Mon Mar 20 09:44:18 2017 -0500
checks: Warn on node name unit-addresses with '0x' or leading 0s
Node name unit-addresses should generally never begin with 0x or leading
0s. Add warnings to check for these cases, but only for nodes without a
known bus type as there should be better bus specific checks of the
unit address in those cases. Any unit addresses that don't follow the
general rule will need to add a new bus type. There aren't any known
ones ATM.
Reviewed-by: David Gibson <david at gibson.dropbear.id.au>
Signed-off-by: Rob Herring <robh at kernel.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
checks.c | 25 +++++++++++++++++++++++++
tests/run_tests.sh | 2 ++
tests/unit-addr-leading-0s.dts | 12 ++++++++++++
tests/unit-addr-leading-0x.dts | 12 ++++++++++++
4 files changed, 51 insertions(+)
diff --git a/checks.c b/checks.c
index 4ae5c62..5adfc8f 100644
--- a/checks.c
+++ b/checks.c
@@ -880,6 +880,30 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
}
WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge);
+static void check_unit_address_format(struct check *c, struct dt_info *dti,
+ struct node *node)
+{
+ const char *unitname = get_unitname(node);
+
+ if (node->parent && node->parent->bus)
+ return;
+
+ if (!unitname[0])
+ return;
+
+ if (!strncmp(unitname, "0x", 2)) {
+ FAIL(c, dti, "Node %s unit name should not have leading \"0x\"",
+ node->fullpath);
+ /* skip over 0x for next test */
+ unitname += 2;
+ }
+ if (unitname[0] == '0' && isxdigit(unitname[1]))
+ FAIL(c, dti, "Node %s unit name should not have leading 0s",
+ node->fullpath);
+}
+WARNING(unit_address_format, check_unit_address_format, NULL,
+ &node_name_format, &pci_bridge, &simple_bus_bridge);
+
/*
* Style checks
*/
@@ -951,6 +975,7 @@ static struct check *check_table[] = {
&addr_size_cells, ®_format, &ranges_format,
&unit_address_vs_reg,
+ &unit_address_format,
&pci_bridge,
&pci_device_reg,
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index ed489db..0f5c3db 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -540,6 +540,8 @@ dtc_tests () {
check_tests obsolete-chosen-interrupt-controller.dts obsolete_chosen_interrupt_controller
check_tests reg-without-unit-addr.dts unit_address_vs_reg
check_tests unit-addr-without-reg.dts unit_address_vs_reg
+ check_tests unit-addr-leading-0x.dts unit_address_format
+ check_tests unit-addr-leading-0s.dts unit_address_format
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 prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb
diff --git a/tests/unit-addr-leading-0s.dts b/tests/unit-addr-leading-0s.dts
new file mode 100644
index 0000000..cc017e9
--- /dev/null
+++ b/tests/unit-addr-leading-0s.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bus {
+ node at 001 {
+ reg = <1 0>;
+ };
+ };
+};
diff --git a/tests/unit-addr-leading-0x.dts b/tests/unit-addr-leading-0x.dts
new file mode 100644
index 0000000..74f1967
--- /dev/null
+++ b/tests/unit-addr-leading-0x.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bus {
+ node at 0x1 {
+ reg = <1 0>;
+ };
+ };
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list