mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/6] ppc: bootm: Drop usage of data->oftree
Date: Wed,  6 Jun 2018 09:11:27 +0200	[thread overview]
Message-ID: <20180606071129.28884-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180606071129.28884-1-s.hauer@pengutronix.de>

The ppc bootm code uses data->oftree to store its private data pointers.
Drop this and use a local variable instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/ppc/lib/ppclinux.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c
index 67649f3b46..05c29be7da 100644
--- a/arch/ppc/lib/ppclinux.c
+++ b/arch/ppc/lib/ppclinux.c
@@ -14,7 +14,8 @@
 #include <restart.h>
 #include <fs.h>
 
-static int bootm_relocate_fdt(struct image_data *data)
+static struct fdt_header *bootm_relocate_fdt(struct image_data *data,
+					     struct fdt_header *fdt)
 {
 	void *os = (void *)data->os_address;
 	void *newfdt;
@@ -24,10 +25,10 @@ static int bootm_relocate_fdt(struct image_data *data)
 		 * Put the DTB above if there is no space
 		 * below.
 		 */
-		if (os < (void *)data->oftree->totalsize) {
+		if (os < (void *)fdt->totalsize) {
 			os = (void *)PAGE_ALIGN((phys_addr_t)os +
 					data->os->header.ih_size);
-			os += data->oftree->totalsize;
+			os += fdt->totalsize;
 			if (os < LINUX_TLB1_MAX_ADDR)
 				os = LINUX_TLB1_MAX_ADDR;
 		}
@@ -35,17 +36,15 @@ static int bootm_relocate_fdt(struct image_data *data)
 
 	if (os > LINUX_TLB1_MAX_ADDR) {
 		pr_crit("Unable to relocate DTB to Linux TLB\n");
-		return 1;
+		return NULL;
 	}
 
-	newfdt = (void *)PAGE_ALIGN_DOWN((phys_addr_t)os -
-			data->oftree->totalsize);
-	memcpy(newfdt, data->oftree, data->oftree->totalsize);
-	free(data->oftree);
-	data->oftree = newfdt;
+	newfdt = (void *)PAGE_ALIGN_DOWN((phys_addr_t)os - fdt->totalsize);
+	memcpy(newfdt, fdt, fdt->totalsize);
+	free(fdt);
 
 	pr_info("Relocating device tree to 0x%p\n", newfdt);
-	return 0;
+	return newfdt;
 }
 
 static int do_bootm_linux(struct image_data *data)
@@ -53,13 +52,14 @@ static int do_bootm_linux(struct image_data *data)
 	void	(*kernel)(void *, void *, unsigned long,
 			unsigned long, unsigned long);
 	int ret;
+	struct fdt_header *fdt;
 
 	ret = bootm_load_os(data, data->os_address);
 	if (ret)
 		return ret;
 
-	data->oftree = of_get_fixed_tree(data->of_root_node);
-	if (!data->oftree) {
+	fdt = of_get_fixed_tree(data->of_root_node);
+	if (!fdt) {
 		pr_err("bootm: No devicetree given.\n");
 		return -EINVAL;
 	}
@@ -71,15 +71,14 @@ static int do_bootm_linux(struct image_data *data)
 	 * Linux mapped TLB.
 	 */
 	if (IS_ENABLED(CONFIG_MPC85xx)) {
-		void *addr = data->oftree;
-
-		if ((addr + data->oftree->totalsize) > LINUX_TLB1_MAX_ADDR) {
-			if (bootm_relocate_fdt(data))
+		if (((void *)fdt + fdt->totalsize) > LINUX_TLB1_MAX_ADDR) {
+			fdt = bootm_relocate_fdt(data, fdt);
+			if (!fdt)
 				goto error;
 		}
 	}
 
-	fdt_add_reserve_map(data->oftree);
+	fdt_add_reserve_map(fdt);
 
 	kernel = (void *)(data->os_address + data->os_entry);
 
@@ -91,7 +90,7 @@ static int do_bootm_linux(struct image_data *data)
 	 *   r6: NULL
 	 *   r7: NULL
 	 */
-	kernel(data->oftree, kernel, 0, 0, 0);
+	kernel(fdt, kernel, 0, 0, 0);
 
 	restart_machine();
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-06-06  7:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06  7:11 [PATCH 0/6] bootm: split bootm_load_devicetree into two functions Sascha Hauer
2018-06-06  7:11 ` [PATCH 1/6] ARM: bootm: drop usage of data->oftree Sascha Hauer
2018-06-06  7:11 ` [PATCH 2/6] ppc: bootm: rename variables Sascha Hauer
2018-06-06  7:11 ` [PATCH 3/6] ppc: bootm: remove unnecessary parameter Sascha Hauer
2018-06-06  7:11 ` Sascha Hauer [this message]
2018-06-06  7:11 ` [PATCH 5/6] bootm: Drop data->oftree Sascha Hauer
2018-06-06  7:11 ` [PATCH 6/6] bootm: Split bootm_load_devicetree into two functions 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=20180606071129.28884-5-s.hauer@pengutronix.de \
    --to=s.hauer@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