From 70ea799f6b6ddcd92b94420a2d352a73f0f9ff08 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 4 May 2017 12:50:59 +0200 Subject: state: Create alias in of_state_fixup() 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 --- common/state/state.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'common/state') 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); -- cgit v1.2.3