[PATCH 2/2] pstore: ram: use new of_fixup_reserved_memory() helper
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Aug 15 04:42:46 PDT 2022
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 at 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
More information about the barebox
mailing list