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 4/4] state: Create alias in of_state_fixup()
Date: Thu,  4 May 2017 13:02:19 +0200	[thread overview]
Message-ID: <20170504110219.17929-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170504110219.17929-1-s.hauer@pengutronix.de>

When the kernel device tree is fixed up we assume that it doesn't
have a state node, so we must also assume that it doesn't have
a alias. Create it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/state/state.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/state/state.c b/common/state/state.c
index 41bee0fdc5..b4a634fa99 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -407,7 +407,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 {
 	struct state *state = ctx;
 	const char *compatible = "barebox,state";
-	struct device_node *new_node, *node, *parent, *backend_node;
+	struct device_node *new_node, *node, *parent, *backend_node, *aliases;
 	struct property *p;
 	int ret;
 	phandle phandle;
@@ -520,6 +520,17 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 	if (ret)
 		goto out;
 
+	aliases = of_create_node(root, "/aliases");
+	if (!aliases) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = of_set_property(aliases, state->name, new_node->full_name,
+			      strlen(new_node->full_name) + 1, 1);
+	if (ret)
+		goto out;
+
 	/* delete existing node */
 	if (node)
 		of_delete_node(node);
-- 
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 ` [PATCH 3/4] state: Make an alias mandatory Sascha Hauer
2017-05-04 11:02 ` Sascha Hauer [this message]

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-5-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