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 2/2] state: find backend node with its reproducible name
Date: Tue, 20 Feb 2018 14:45:26 +0100	[thread overview]
Message-ID: <20180220134526.18280-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180220134526.18280-1-s.hauer@pengutronix.de>

When fixing up the kernels state nodes we depended on the full node path
of the input device tree. This does not work when the kernel device tree
has different names. This has happened lately when the i.MX6 device
trees got their leading zeroes removed from the node names.

Use of_find_node_by_reproducible_name() to find the node corresponding
to the storage backend node in the kernel device tree.

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

diff --git a/common/state/state.c b/common/state/state.c
index fdf10991aa..2a91c6aa6a 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -470,7 +470,8 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 	}
 
 	/* backend phandle */
-	backend_node = of_find_node_by_devpath(root, state->backend_path);
+	backend_node = of_find_node_by_reproducible_name(root,
+						state->backend_reproducible_name);
 	if (!backend_node) {
 		ret = -ENODEV;
 		goto out;
@@ -550,6 +551,7 @@ void state_release(struct state *state)
 	state_storage_free(&state->storage);
 	state_format_free(state->format);
 	free(state->backend_path);
+	free(state->backend_reproducible_name);
 	free(state->of_path);
 	free(state);
 }
@@ -595,6 +597,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly)
 		goto out_release_state;
 	}
 
+	state->backend_reproducible_name = of_get_reproducible_name(partition_node);
+
 	ret = of_property_read_string(node, "backend-type", &backend_type);
 	if (ret) {
 		dev_dbg(&state->dev, "Missing 'backend-type' property\n");
diff --git a/common/state/state.h b/common/state/state.h
index fcc6b9f5cd..cde6a34c23 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -113,6 +113,7 @@ struct state {
 	struct state_backend_format *format;
 	struct state_backend_storage storage;
 	char *backend_path;
+	char *backend_reproducible_name;
 };
 
 enum state_convert {
-- 
2.16.1


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

      reply	other threads:[~2018-02-20 13:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 13:45 [PATCH 1/2] state: remove unused arguments from state_new_from_node() Sascha Hauer
2018-02-20 13:45 ` 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=20180220134526.18280-2-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