From: Clement Leger <cleger@kalray.eu>
To: Sascha Hauer <s.hauer@pengutronix.de>, barebox@lists.infradead.org
Cc: Clement Leger <cleger@kalray.eu>
Subject: [PATCH v2 2/2] of: base: parse all available memory nodes
Date: Wed, 25 Mar 2020 18:27:37 +0100 [thread overview]
Message-ID: <20200325172737.8621-3-cleger@kalray.eu> (raw)
In-Reply-To: <20200325172737.8621-1-cleger@kalray.eu>
Currently, barebox only parse one memory node which is either the
"/memory" node or the first node with device_type == "memory".
However, the use of multiple memory nodes with device_type = "memory"
property is allowed by the device tree specification and already
correctly parsed by Linux kernel.
In order to fix that, add of_probe_memory function which loop over all
available memory nodes matching device_type == "memory".
Signed-off-by: Clement Leger <cleger@kalray.eu>
---
drivers/of/base.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 2ea8d7516..6d13b66a0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2062,9 +2062,23 @@ const struct of_device_id of_default_bus_match_table[] = {
}
};
+static void of_probe_memory(void)
+{
+ struct device_node *memory = root_node;
+
+ /* Parse all available node with "memory" device_type */
+ while (1) {
+ memory = of_find_node_by_type(memory, "memory");
+ if (!memory)
+ break;
+
+ of_add_memory(memory, false);
+ }
+}
+
int of_probe(void)
{
- struct device_node *memory, *firmware;
+ struct device_node *firmware;
if(!root_node)
return -ENODEV;
@@ -2075,11 +2089,7 @@ int of_probe(void)
if (of_model)
barebox_set_model(of_model);
- memory = of_find_node_by_path("/memory");
- if (!memory)
- memory = of_find_node_by_type(root_node, "memory");
- if (memory)
- of_add_memory(memory, false);
+ of_probe_memory();
firmware = of_find_node_by_path("/firmware");
if (firmware)
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-03-25 17:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-16 11:00 [PATCH 0/2] Allow parsing more than one memory node Clement Leger
2020-03-16 11:00 ` [PATCH 1/2] of: base: parse all available memory nodes Clement Leger
2020-03-23 10:12 ` Sascha Hauer
2020-03-23 10:21 ` Clément Leger
2020-03-23 10:31 ` Ahmad Fatoum
2020-03-25 9:29 ` Sascha Hauer
2020-06-18 10:16 ` Ahmad Fatoum
2020-03-16 11:00 ` [PATCH 2/2] of: base: allow of_add_memory to be called multiple times Clement Leger
2020-03-25 17:27 ` [PATCH v2 0/2] Allow parsing more than one memory node Clement Leger
2020-03-25 17:27 ` [PATCH v2 1/2] of: base: allow of_add_memory to be called multiple times Clement Leger
2020-03-25 17:27 ` Clement Leger [this message]
2020-03-30 5:31 ` [PATCH v2 0/2] Allow parsing more than one memory node Sascha Hauer
2020-03-17 7:35 ` [PATCH " Sam Ravnborg
2020-03-17 8:19 ` Clément Leger
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=20200325172737.8621-3-cleger@kalray.eu \
--to=cleger@kalray.eu \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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