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] of: fix reproducible node name for legacy vs. new partition binding
Date: Wed, 17 Oct 2018 10:47:07 +0200	[thread overview]
Message-ID: <20181017084707.11878-1-s.hauer@pengutronix.de> (raw)

the of_reproducible_name mechanism is used to find a partition node
from the barebox devicetree in the Linux devicetree. Unfortunately
we have two different partition bindings. In the legacy one the partition
nodes are directly under the hardware devicenode whereas in the new
binding the partitions are under an additional partitions subnode.
This means we get two different (not so) reproducible names when
the barebox devicetree uses the legacy binding and the Linux devicetree
uses the new binding (or the other way round). To get the same
name then for these cases we drop the partitions subnode from the
reproducible name.

This makes the partition fixup in barebox-state work when the barebox
devicetree uses another binding than the Linux devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 drivers/of/base.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index fc01a99ef2..f9b1c3c4cb 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2274,6 +2274,18 @@ char *of_get_reproducible_name(struct device_node *node)
 		return basprintf("[0x%llx]", addr);
 	}
 
+	/*
+	 * Special workaround for the of partition binding. In the old binding
+	 * the partitions are directly under the hardware devicenode whereas in
+	 * the new binding the partitions are in an extra subnode with
+	 * "fixed-partitions" compatible. We skip this extra subnode from the
+	 * reproducible name to get the same name for both bindings.
+	 */
+	if (node->parent &&
+	    of_device_is_compatible(node->parent, "fixed-partitions")) {
+		node = node->parent;
+	}
+
 	na = of_n_addr_cells(node);
 
 	offset = of_read_number(reg, na);
-- 
2.19.0


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

             reply	other threads:[~2018-10-17  8:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17  8:47 Sascha Hauer [this message]
2018-10-17 11:07 ` Schenk, Gavin
2018-10-18  7:23   ` s.hauer
2018-10-18  9:07     ` Schenk, Gavin

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=20181017084707.11878-1-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