[PATCH 42/42] state: find device node from device path, not from device node path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 common/state/state.c | 10 +++++-----
 common/state/state.h |  2 +-
 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 {
-- 
2.11.0


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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux