[PATCH 4/4] state: Create alias in of_state_fixup()

Sascha Hauer s.hauer at pengutronix.de
Thu May 4 04:02:19 PDT 2017


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




More information about the barebox mailing list