mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/4] state: Make an alias mandatory
Date: Thu,  4 May 2017 13:02:18 +0200	[thread overview]
Message-ID: <20170504110219.17929-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170504110219.17929-1-s.hauer@pengutronix.de>

The userspace barebox-state utility gets confused when no alias exists.
Make the alias mandatory, so that people make it right^tm without having
to ask.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/barebox/barebox,state.rst | 6 ++++++
 common/state/state.c                                        | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst
index 51b874a8be..06a0d100c8 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
@@ -32,6 +32,8 @@ Required properties:
 * ``backend``: contains a phandle to the device/partition which holds the
   actual state data.
 * ``backend-type``: should be ``raw`` or ``dtb``.
+* additionally a state node must have an alias in the /aliases/ node pointing
+  to it.
 
 Optional properties:
 
@@ -74,6 +76,10 @@ Optional properties:
 
 Example::
 
+  /aliases {
+  	state = &state;
+  };
+
   state: state {
   	magic = <0x27031977>;
   	compatible = "barebox,state";
diff --git a/common/state/state.c b/common/state/state.c
index c3c8b768c7..41bee0fdc5 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -567,8 +567,10 @@ struct state *state_new_from_node(struct device_node *node, char *path,
 	uint32_t stridesize;
 
 	alias = of_alias_get(node);
-	if (!alias)
-		alias = node->name;
+	if (!alias) {
+		pr_err("State node %s does not have an alias in the /aliases/ node\n", node->full_name);
+		return ERR_PTR(-EINVAL);
+	}
 
 	state = state_new(alias);
 	if (IS_ERR(state))
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-05-04 11:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 11:02 state fixes/clarifications Sascha Hauer
2017-05-04 11:02 ` [PATCH 1/4] state: Binding: remove @0 from node name Sascha Hauer
2017-05-04 11:02 ` [PATCH 2/4] state: warn when a state node will be overwritten Sascha Hauer
2017-05-08  6:15   ` Uwe Kleine-König
2017-05-08 11:58     ` Sascha Hauer
2017-05-04 11:02 ` Sascha Hauer [this message]
2017-05-04 11:02 ` [PATCH 4/4] state: Create alias in of_state_fixup() Sascha Hauer

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=20170504110219.17929-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox