[PATCH 2/2] pstore: ram: use new of_fixup_reserved_memory() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux