summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-30 16:33:26 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:53 +0200
commite627903d59b7f7d085e53a0dc9ed942bcc63dff9 (patch)
tree46b6e6204ba99b43b98333fbbf7626321f77dd6e /common/state
parent9d6d91931afb8f038a58d18471dccd65bdd95cfd (diff)
downloadbarebox-e627903d59b7f7d085e53a0dc9ed942bcc63dff9.tar.gz
barebox-e627903d59b7f7d085e53a0dc9ed942bcc63dff9.tar.xz
state: find device node from device path, not from device node path
The device node path may change from the internal device tree to the one Linux is started with, so using this path to fixup the tree is not very robust. Instead, use of_find_node_by_devpath() which has been created for exactly this purpose. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state')
-rw-r--r--common/state/state.c10
-rw-r--r--common/state/state.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/common/state/state.c b/common/state/state.c
index bdeda2e5a1..94a423b825 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -461,7 +461,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
}
/* backend phandle */
- backend_node = of_find_node_by_path_from(root, state->of_backend_path);
+ backend_node = of_find_node_by_devpath(root, state->backend_path);
if (!backend_node) {
ret = -ENODEV;
goto out;
@@ -529,7 +529,7 @@ void state_release(struct state *state)
unregister_device(&state->dev);
state_storage_free(&state->storage);
state_format_free(state->format);
- free(state->of_backend_path);
+ free(state->backend_path);
free(state->of_path);
free(state);
}
@@ -591,6 +591,8 @@ struct state *state_new_from_node(struct device_node *node, char *path,
}
}
+ state->backend_path = xstrdup(path);
+
ret = of_property_read_string(node, "backend-type", &backend_type);
if (ret) {
goto out_release_state;
@@ -617,8 +619,6 @@ struct state *state_new_from_node(struct device_node *node, char *path,
if (ret)
goto out_release_state;
- state->of_backend_path = xstrdup(of_path);
-
if (readonly)
state_backend_set_readonly(state);
@@ -693,7 +693,7 @@ void state_info(void)
if (state->format)
printf("(backend: %s, path: %s)\n",
state->format->name,
- state->of_backend_path);
+ state->backend_path);
else
printf("(no backend)\n");
}
diff --git a/common/state/state.h b/common/state/state.h
index 5e240c4773..ead8cc88c1 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -104,7 +104,7 @@ struct state {
struct state_backend_format *format;
struct state_backend_storage storage;
- char *of_backend_path;
+ char *backend_path;
};
enum state_convert {