From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] pstore: ram: use new of_fixup_reserved_memory() helper
Date: Mon, 15 Aug 2022 13:42:46 +0200 [thread overview]
Message-ID: <20220815114246.2275465-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220815114246.2275465-1-a.fatoum@pengutronix.de>
The new of_fixup_reserved_memory() can handle everything that the
opencoded version in pstore can with the added benefit that it correctly
handles #address-cells/#size-cells != 1, which previously were just
assumed to be 1.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/pstore/ram.c | 31 +++++++++----------------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 0d8bb8f418f4..1f105c2a384e 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -474,35 +474,22 @@ static int ramoops_of_fixup(struct device_node *root, void *data)
{
struct ramoops_platform_data *pdata = data;
struct device_node *node;
- u32 reg[2];
+ struct resource res = {};
int ret;
- node = of_get_child_by_name(root, "reserved-memory");
- if (!node) {
- pr_info("Adding reserved-memory node\n");
- node = of_create_node(root, "/reserved-memory");
- if (!node)
- return -ENOMEM;
+ res.start = pdata->mem_address;
+ res.end = res.start + pdata->mem_size;
+ res.name = "ramoops";
- of_property_write_u32(node, "#address-cells", 1);
- of_property_write_u32(node, "#size-cells", 1);
- of_new_property(node, "ranges", NULL, 0);
- }
+ ret = of_fixup_reserved_memory(root, &res);
+ if (ret)
+ return ret;
node = of_get_child_by_name(node, "ramoops");
- if (!node) {
- pr_info("Adding ramoops node\n");
- node = of_create_node(root, "/reserved-memory/ramoops");
- if (!node)
- return -ENOMEM;
- }
+ if (!node)
+ return -ENOMEM;
ret = of_property_write_string(node, "compatible", "ramoops");
- if (ret)
- return ret;
- reg[0] = pdata->mem_address;
- reg[1] = pdata->mem_size;
- ret = of_property_write_u32_array(node, "reg", reg, 2);
if (ret)
return ret;
--
2.30.2
next prev parent reply other threads:[~2022-08-15 11:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 11:42 [PATCH 1/2] of: add " Ahmad Fatoum
2022-08-15 11:42 ` Ahmad Fatoum [this message]
2022-08-15 14:17 ` [PATCH] fixup! pstore: ram: use " Ahmad Fatoum
2022-08-16 8:18 ` [PATCH 1/2] of: add " Sascha Hauer
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=20220815114246.2275465-2-a.fatoum@pengutronix.de \
--to=a.fatoum@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