diff mbox series

[v4,09/21] pstore/ram : Export ramoops_parse_dt() symbol

Message ID 1687955688-20809-10-git-send-email-quic_mojha@quicinc.com
State New
Headers show
Series [v4,01/21] docs: qcom: Add qualcomm minidump guide | expand

Commit Message

Mukesh Ojha June 28, 2023, 12:34 p.m. UTC
It is possible if some driver do not want ramoops region to
be static instead it sets up the mem_address and mem_size
and use everything what this driver has to offer. To offer
this convenience export ramoops_parse_dt() function.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 fs/pstore/ram.c            | 26 ++++++++++++++++++--------
 include/linux/pstore_ram.h |  2 ++
 2 files changed, 20 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ade66dbe5f39..6bb66d044bef 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -638,7 +638,7 @@  static int ramoops_parse_dt_u32(struct platform_device *pdev,
 	return 0;
 }
 
-static int ramoops_parse_dt(struct platform_device *pdev,
+int ramoops_parse_dt(struct platform_device *pdev,
 			    struct ramoops_platform_data *pdata)
 {
 	struct device_node *of_node = pdev->dev.of_node;
@@ -649,15 +649,24 @@  static int ramoops_parse_dt(struct platform_device *pdev,
 
 	dev_dbg(&pdev->dev, "using Device Tree\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev,
-			"failed to locate DT /reserved-memory resource\n");
-		return -EINVAL;
+	/*
+	 * It is possible if some driver do not want ramoops
+	 * region to be static instead it sets up the mem_address
+	 * and mem_size and use everything what this driver has
+	 * to offer.
+	 */
+	if (!pdata->mem_address && !pdata->mem_size) {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res) {
+			dev_err(&pdev->dev,
+				"failed to locate DT /reserved-memory resource\n");
+			return -EINVAL;
+		}
+
+		pdata->mem_size = resource_size(res);
+		pdata->mem_address = res->start;
 	}
 
-	pdata->mem_size = resource_size(res);
-	pdata->mem_address = res->start;
 	/*
 	 * Setting "unbuffered" is deprecated and will be ignored if
 	 * "mem_type" is also specified.
@@ -713,6 +722,7 @@  static int ramoops_parse_dt(struct platform_device *pdev,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ramoops_parse_dt);
 
 static int ramoops_probe(struct platform_device *pdev)
 {
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 9d65ff94e216..55df4e631a25 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -8,6 +8,7 @@ 
 #ifndef __LINUX_PSTORE_RAM_H__
 #define __LINUX_PSTORE_RAM_H__
 
+#include <linux/platform_device.h>
 #include <linux/pstore.h>
 
 struct persistent_ram_ecc_info {
@@ -39,4 +40,5 @@  struct ramoops_platform_data {
 	struct persistent_ram_ecc_info ecc_info;
 };
 
+int ramoops_parse_dt(struct platform_device *, struct ramoops_platform_data *);
 #endif