All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v2 6/6] checks: add a chosen node check
Date: Tue, 12 Dec 2017 16:46:29 -0600	[thread overview]
Message-ID: <20171212224629.28738-6-robh@kernel.org> (raw)
In-Reply-To: <20171212224629.28738-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Add a check for /chosen node. This checks that chosen is located at the
root level and that bootargs and stdout-path properties are strings.

Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
v2:
- New patch making an explicit chosen node test.

 checks.c                         | 32 ++++++++++++++++++++++++++++++++
 tests/bad-chosen-bootargs.dts    |  7 +++++++
 tests/bad-chosen-location.dts    |  8 ++++++++
 tests/bad-chosen-stdout-path.dts |  9 +++++++++
 tests/run_tests.sh               |  3 +++
 5 files changed, 59 insertions(+)
 create mode 100644 tests/bad-chosen-bootargs.dts
 create mode 100644 tests/bad-chosen-location.dts
 create mode 100644 tests/bad-chosen-stdout-path.dts

diff --git a/checks.c b/checks.c
index 66e5fd6405a5..234e97ffb905 100644
--- a/checks.c
+++ b/checks.c
@@ -636,6 +636,37 @@ static void check_names_is_string_list(struct check *c, struct dt_info *dti,
 }
 WARNING(names_is_string_list, check_names_is_string_list, NULL);
 
+static void check_chosen_node(struct check *c, struct dt_info *dti,
+				    struct node *node)
+{
+	struct property *prop;
+
+	if (!streq(node->name, "chosen"))
+		return;
+
+	if (node->parent->parent) {
+		FAIL(c, dti, "chosen node must be at root node (%s)",
+		     node->parent->name);
+	}
+
+	prop = get_property(node, "bootargs");
+	if (prop) {
+		c->data = prop->name;
+		check_is_string(c, dti, node);
+	}
+
+	prop = get_property(node, "linux,stdout-path");
+	if (prop)
+		FAIL(c, dti, "Use 'stdout-path' instead of 'linux,stdout-path'");
+
+	prop = get_property(node, "stdout-path");
+	if (prop) {
+		c->data = prop->name;
+		check_is_string(c, dti, node);
+	}
+}
+WARNING(chosen_node, check_chosen_node, NULL);
+
 static void check_alias_paths(struct check *c, struct dt_info *dti,
 				    struct node *node)
 {
@@ -1377,6 +1408,7 @@ static struct check *check_table[] = {
 	&interrupts_property,
 
 	&alias_paths,
+	&chosen_node,
 
 	&always_fail,
 };
diff --git a/tests/bad-chosen-bootargs.dts b/tests/bad-chosen-bootargs.dts
new file mode 100644
index 000000000000..fb72a820b340
--- /dev/null
+++ b/tests/bad-chosen-bootargs.dts
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+/ {
+	chosen {
+		bootargs = <0xdeadbeef>;
+	};
+};
diff --git a/tests/bad-chosen-location.dts b/tests/bad-chosen-location.dts
new file mode 100644
index 000000000000..0f6de5ed7ed3
--- /dev/null
+++ b/tests/bad-chosen-location.dts
@@ -0,0 +1,8 @@
+/dts-v1/;
+
+/ {
+	node2 {
+		chosen {
+		};
+	};
+};
diff --git a/tests/bad-chosen-stdout-path.dts b/tests/bad-chosen-stdout-path.dts
new file mode 100644
index 000000000000..a022e68e96ec
--- /dev/null
+++ b/tests/bad-chosen-stdout-path.dts
@@ -0,0 +1,9 @@
+/dts-v1/;
+
+/ {
+	chosen {
+		linux,stdout-path = "foo";
+		stdout-path = <1>;
+	};
+
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index d36dffbc4ef9..8b45b81b2e61 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-location.dts chosen_node
+    check_tests bad-chosen-bootargs.dts chosen_node
+    check_tests bad-chosen-stdout-path.dts chosen_node
     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
-- 
2.14.1

  parent reply	other threads:[~2017-12-12 22:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 22:46 [PATCH v2 1/6] checks: add a string check for 'label' property Rob Herring
     [not found] ` <20171212224629.28738-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-12 22:46   ` [PATCH v2 2/6] checks: add string list check Rob Herring
     [not found]     ` <20171212224629.28738-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-13  9:24       ` David Gibson
2017-12-12 22:46   ` [PATCH v2 3/6] checks: add string list check for *-names properties Rob Herring
     [not found]     ` <20171212224629.28738-3-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-13  9:28       ` David Gibson
2017-12-12 22:46   ` [PATCH v2 4/6] checks: check for #{size,address}-cells without child nodes Rob Herring
     [not found]     ` <20171212224629.28738-4-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-13 10:06       ` David Gibson
2017-12-12 22:46   ` [PATCH v2 5/6] checks: add aliases node checks Rob Herring
2017-12-12 22:46   ` Rob Herring [this message]
     [not found]     ` <20171212224629.28738-6-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-12-13 10:39       ` [PATCH v2 6/6] checks: add a chosen node check David Gibson
2017-12-13  9:20   ` [PATCH v2 1/6] checks: add a string check for 'label' property David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171212224629.28738-6-robh@kernel.org \
    --to=robh-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.