linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: linuxppc-dev@lists.ozlabs.org,
	devicetree-discuss@lists.ozlabs.org, sparclinux@vger.kernel.org,
	microblaze-uclinux@itee.uq.edu.au, benh@kernel.crashing.org,
	sfr@canb.auug.org.au, davem@davemloft.net, monstr@monstr.eu
Subject: [PATCH 05/11] of/flattree: merge early_init_dt_scan_chosen()
Date: Tue, 24 Nov 2009 01:18:48 -0700	[thread overview]
Message-ID: <20091124081840.6216.49419.stgit@angua> (raw)
In-Reply-To: <20091124081316.6216.66310.stgit@angua>

Merge common code between PowerPC and Microblaze.  This patch
splits the arch-specific stuff out into a new function,
early_init_dt_scan_chosen_arch().

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 arch/microblaze/kernel/prom.c |   44 ++-------------------------------------
 arch/powerpc/kernel/prom.c    |   46 +++++++++--------------------------------
 drivers/of/fdt.c              |   38 ++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h        |    3 +++
 4 files changed, 53 insertions(+), 78 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 7760186..7ee021f 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	return 0;
 }
 
-static int __init early_init_dt_scan_chosen(unsigned long node,
-				const char *uname, int depth, void *data)
+void __init early_init_dt_scan_chosen_arch(unsigned long node)
 {
-	unsigned long l;
-	char *p;
-
-	pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
-
-	if (depth != 1 ||
-		(strcmp(uname, "chosen") != 0 &&
-				strcmp(uname, "chosen@0") != 0))
-		return 0;
-
-#ifdef CONFIG_KEXEC
-	lprop = (u64 *)of_get_flat_dt_prop(node,
-				"linux,crashkernel-base", NULL);
-	if (lprop)
-		crashk_res.start = *lprop;
-
-	lprop = (u64 *)of_get_flat_dt_prop(node,
-				"linux,crashkernel-size", NULL);
-	if (lprop)
-		crashk_res.end = crashk_res.start + *lprop - 1;
-#endif
-
-	early_init_dt_check_for_initrd(node);
-
-	/* Retreive command line */
-	p = of_get_flat_dt_prop(node, "bootargs", &l);
-	if (p != NULL && l > 0)
-		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
-
-#ifdef CONFIG_CMDLINE
-#ifndef CONFIG_CMDLINE_FORCE
-	if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
-#endif
-		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-	pr_debug("Command line is: %s\n", cmd_line);
-
-	/* break now */
-	return 1;
+	/* No Microblaze specific code here */
 }
 
 static int __init early_init_dt_scan_memory(unsigned long node,
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 43cdba2..2c7d4a3 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -367,18 +367,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	return 0;
 }
 
-static int __init early_init_dt_scan_chosen(unsigned long node,
-					    const char *uname, int depth, void *data)
+void __init early_init_dt_scan_chosen_arch(unsigned long node)
 {
 	unsigned long *lprop;
-	unsigned long l;
-	char *p;
-
-	DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
-
-	if (depth != 1 ||
-	    (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
-		return 0;
 
 #ifdef CONFIG_PPC64
 	/* check if iommu is forced on or off */
@@ -389,17 +380,17 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
 #endif
 
 	/* mem=x on the command line is the preferred mechanism */
- 	lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
- 	if (lprop)
- 		memory_limit = *lprop;
+	lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
+	if (lprop)
+		memory_limit = *lprop;
 
 #ifdef CONFIG_PPC64
- 	lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL);
- 	if (lprop)
- 		tce_alloc_start = *lprop;
- 	lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);
- 	if (lprop)
- 		tce_alloc_end = *lprop;
+	lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL);
+	if (lprop)
+		tce_alloc_start = *lprop;
+	lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);
+	if (lprop)
+		tce_alloc_end = *lprop;
 #endif
 
 #ifdef CONFIG_KEXEC
@@ -411,23 +402,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
 	if (lprop)
 		crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
-
-	early_init_dt_check_for_initrd(node);
-
-	/* Retreive command line */
- 	p = of_get_flat_dt_prop(node, "bootargs", &l);
-	if (p != NULL && l > 0)
-		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
-
-#ifdef CONFIG_CMDLINE
-	if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
-		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-	DBG("Command line is: %s\n", cmd_line);
-
-	/* break now */
-	return 1;
 }
 
 #ifdef CONFIG_PPC_PSERIES
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ebce509..616a476 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -15,6 +15,10 @@
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 
+#ifdef CONFIG_PPC
+#include <asm/machdep.h>
+#endif /* CONFIG_PPC */
+
 int __initdata dt_root_addr_cells;
 int __initdata dt_root_size_cells;
 
@@ -440,6 +444,40 @@ u64 __init dt_mem_next_cell(int s, u32 **cellp)
 	return of_read_number(p, s);
 }
 
+int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
+				     int depth, void *data)
+{
+	unsigned long l;
+	char *p;
+
+	pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
+
+	if (depth != 1 ||
+	    (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
+		return 0;
+
+	early_init_dt_check_for_initrd(node);
+
+	/* Retreive command line */
+	p = of_get_flat_dt_prop(node, "bootargs", &l);
+	if (p != NULL && l > 0)
+		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
+
+#ifdef CONFIG_CMDLINE
+#ifndef CONFIG_CMDLINE_FORCE
+	if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
+#endif
+		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif /* CONFIG_CMDLINE */
+
+	early_init_dt_scan_chosen_arch(node);
+
+	pr_debug("Command line is: %s\n", cmd_line);
+
+	/* break now */
+	return 1;
+}
+
 /**
  * unflatten_device_tree - create tree of device_nodes from flat blob
  *
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index d1a37e5..8118d45 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -71,6 +71,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
 				 unsigned long *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
 extern unsigned long of_get_flat_dt_root(void);
+extern void early_init_dt_scan_chosen_arch(unsigned long node);
+extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
+				     int depth, void *data);
 extern void early_init_dt_check_for_initrd(unsigned long node);
 extern u64 dt_mem_next_cell(int s, u32 **cellp);
 

  parent reply	other threads:[~2009-11-24  8:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-24  8:17 [PATCH 00/11] Yet another series of OF merge patches Grant Likely
2009-11-24  8:17 ` [PATCH 01/11] of/flattree: Merge early_init_dt_check_for_initrd() Grant Likely
2009-11-26  3:51   ` Benjamin Herrenschmidt
2009-11-26  4:02     ` Grant Likely
2009-11-24  8:18 ` [PATCH 02/11] of/flattree: Merge earlyinit_dt_scan_root() Grant Likely
2009-11-26  3:54   ` Benjamin Herrenschmidt
2009-11-26  4:03     ` Grant Likely
2009-11-24  8:18 ` [PATCH 03/11] of/flattree: merge dt_mem_next_cell Grant Likely
2009-11-26  3:55   ` Benjamin Herrenschmidt
2009-11-24  8:18 ` [PATCH 04/11] of/flattree: eliminate cell_t typedef Grant Likely
2009-11-26  3:59   ` Benjamin Herrenschmidt
2009-11-26  4:05     ` Grant Likely
2009-11-26  5:27       ` Benjamin Herrenschmidt
2009-11-26 21:36         ` Segher Boessenkool
2009-11-26 21:40           ` Benjamin Herrenschmidt
2009-11-26 23:32           ` David Miller
2009-12-11  6:43         ` Grant Likely
2009-11-26  6:28       ` M. Warner Losh
2009-11-26  7:06         ` Benjamin Herrenschmidt
2009-11-26  7:52           ` Mitch Bradley
2009-11-24  8:18 ` Grant Likely [this message]
2009-11-24  8:19 ` [PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree() Grant Likely
2009-11-26  4:04   ` Benjamin Herrenschmidt
2009-12-11  6:19     ` Grant Likely
2009-12-07  7:08   ` Jeremy Kerr
2009-12-11  6:20     ` Grant Likely
2009-11-24  8:19 ` [PATCH 07/11] of: merge machine_is_compatible() Grant Likely
2009-11-26  4:05   ` Benjamin Herrenschmidt
2009-12-11  6:54     ` Grant Likely
2009-11-24  8:19 ` [PATCH 08/11] of: Merge of_node_get() and of_node_put() Grant Likely
2009-11-26  4:06   ` Benjamin Herrenschmidt
2009-11-24  8:19 ` [PATCH 09/11] of: merge of_attach_node() & of_detach_node() Grant Likely
2009-11-26  4:07   ` Benjamin Herrenschmidt
2009-12-10 22:21     ` Grant Likely
2009-11-24  8:19 ` [PATCH 10/11] microblaze: gut implementation of early_init_dt_scan_cpus() Grant Likely
2009-11-24  8:20 ` [PATCH 11/11] of: unify phandle name in struct device_node Grant Likely
2009-11-24 17:37   ` David Miller
2009-11-24 20:33     ` Grant Likely
2009-11-24 21:10       ` David Miller
2009-11-24 21:06     ` Benjamin Herrenschmidt
2009-11-24 21:39       ` Grant Likely
2009-11-26 12:28 ` [PATCH 00/11] Yet another series of OF merge patches Wolfram Sang

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=20091124081840.6216.49419.stgit@angua \
    --to=grant.likely@secretlab.ca \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=microblaze-uclinux@itee.uq.edu.au \
    --cc=monstr@monstr.eu \
    --cc=sfr@canb.auug.org.au \
    --cc=sparclinux@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).