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 2/2] of: base: allow of_add_memory to be called multiple times
Date: Mon, 16 Mar 2020 12:00:08 +0100 [thread overview]
Message-ID: <20200316110008.2909-3-cleger@kalray.eu> (raw)
In-Reply-To: <20200316110008.2909-1-cleger@kalray.eu>
Currently, of_add_memory can't be called multiple times because it will
always create memory banks by restarting at value 0. This means that, when
adding a second memory bank by calling again of_add_memory, it will be
named ram0 and overwrite the previous one. Fix that by using a static
variable to store the current memory bank number in order to be preserved
from one call to another.
Signed-off-by: Clement Leger <cleger@kalray.eu>
---
drivers/of/base.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index b1a96ee8f..12c58bfb6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2019,6 +2019,8 @@ int of_set_property(struct device_node *np, const char *name, const void *val, i
return 0;
}
+static int mem_bank_num;
+
int of_add_memory(struct device_node *node, bool dump)
{
const char *device_type;
@@ -2030,14 +2032,13 @@ int of_add_memory(struct device_node *node, bool dump)
return -ENXIO;
while (!of_address_to_resource(node, n, &res)) {
- if (!resource_size(&res)) {
- n++;
+ n++;
+ if (!resource_size(&res))
continue;
- }
- of_add_memory_bank(node, dump, n,
+ of_add_memory_bank(node, dump, mem_bank_num,
res.start, resource_size(&res));
- n++;
+ mem_bank_num++;
}
return 0;
--
2.15.0.276.g89ea799
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-03-16 11:03 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 ` Clement Leger [this message]
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 ` [PATCH v2 2/2] of: base: parse all available memory nodes Clement Leger
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=20200316110008.2909-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