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 1/6] ARM: bootm: drop usage of data->oftree
Date: Wed,  6 Jun 2018 09:11:24 +0200	[thread overview]
Message-ID: <20180606071129.28884-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180606071129.28884-1-s.hauer@pengutronix.de>

data->oftree can be replaced with a variable local to the arm code, so
drop usage of data->oftree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/lib32/bootm.c | 43 +++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index c8bf72f0e0..7817e1bdc1 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -130,11 +130,13 @@ static int get_kernel_addresses(size_t image_size,
 	return 0;
 }
 
-static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int swap)
+static int __do_bootm_linux(struct image_data *data, unsigned long free_mem,
+			    int swap, void *fdt)
 {
 	unsigned long kernel;
 	unsigned long initrd_start = 0, initrd_size = 0, initrd_end = 0;
 	enum arm_security_state state = bootm_arm_security_state();
+	void *fdt_load_address = NULL;
 	int ret;
 
 	kernel = data->os_res->start + data->os_entry;
@@ -163,16 +165,21 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
 		free_mem = PAGE_ALIGN(initrd_end + 1);
 	}
 
-	ret = bootm_load_devicetree(data, free_mem);
-	if (ret)
-		return ret;
+	if (fdt) {
+		fdt_load_address = fdt;
+	} else {
+		fdt_load_address = (void *)free_mem;
+		ret = bootm_load_devicetree(data, free_mem);
+		if (ret)
+			return ret;
+	}
 
 	if (bootm_verbose(data)) {
 		printf("\nStarting kernel at 0x%08lx", kernel);
 		if (initrd_size)
 			printf(", initrd at 0x%08lx", initrd_start);
-		if (data->oftree)
-			printf(", oftree at 0x%p", data->oftree);
+		if (fdt_load_address)
+			printf(", oftree at 0x%p", fdt_load_address);
 		printf("...\n");
 	}
 
@@ -188,8 +195,8 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
 	if (data->dryrun)
 		return 0;
 
-	start_linux((void *)kernel, swap, initrd_start, initrd_size, data->oftree,
-		    state);
+	start_linux((void *)kernel, swap, initrd_start, initrd_size,
+		    fdt_load_address, state);
 
 	restart_machine();
 
@@ -212,7 +219,7 @@ static int do_bootm_linux(struct image_data *data)
 	if (ret)
 		return ret;
 
-	return __do_bootm_linux(data, mem_free, 0);
+	return __do_bootm_linux(data, mem_free, 0, NULL);
 }
 
 static struct image_handler uimage_handler = {
@@ -237,7 +244,7 @@ struct zimage_header {
 
 #define ZIMAGE_MAGIC 0x016F2818
 
-static int do_bootz_linux_fdt(int fd, struct image_data *data)
+static int do_bootz_linux_fdt(int fd, struct image_data *data, void **outfdt)
 {
 	struct fdt_header __header, *header;
 	void *oftree;
@@ -245,9 +252,6 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 
 	u32 end;
 
-	if (data->oftree)
-		return -ENXIO;
-
 	header = &__header;
 	ret = read(fd, header, sizeof(*header));
 	if (ret < 0)
@@ -287,8 +291,8 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 			pr_err("unable to unflatten devicetree\n");
 			goto err_free;
 		}
-		data->oftree = of_get_fixed_tree(root);
-		if (!data->oftree) {
+		*outfdt = of_get_fixed_tree(root);
+		if (!*outfdt) {
 			pr_err("Unable to get fixed tree\n");
 			ret = -EINVAL;
 			goto err_free;
@@ -296,7 +300,7 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 
 		free(oftree);
 	} else {
-		data->oftree = oftree;
+		*outfdt = oftree;
 	}
 
 	pr_info("zImage: concatenated oftree detected\n");
@@ -318,6 +322,7 @@ static int do_bootz_linux(struct image_data *data)
 	size_t image_size;
 	unsigned long load_address = data->os_address;
 	unsigned long mem_free;
+	void *fdt;
 
 	fd = open(data->os_file, O_RDONLY);
 	if (fd < 0) {
@@ -388,13 +393,13 @@ static int do_bootz_linux(struct image_data *data)
 			*(u32 *)ptr = swab32(*(u32 *)ptr);
 	}
 
-	ret = do_bootz_linux_fdt(fd, data);
+	ret = do_bootz_linux_fdt(fd, data, &fdt);
 	if (ret && ret != -ENXIO)
 		goto err_out;
 
 	close(fd);
 
-	return __do_bootm_linux(data, mem_free, swap);
+	return __do_bootm_linux(data, mem_free, swap, fdt);
 
 err_out:
 	close(fd);
@@ -559,7 +564,7 @@ static int do_bootm_aimage(struct image_data *data)
 	else
 		mem_free = PAGE_ALIGN(data->os_res->end + SZ_1M);
 
-	return __do_bootm_linux(data, mem_free, 0);
+	return __do_bootm_linux(data, mem_free, 0, NULL);
 
 err_out:
 	linux_bootargs_overwrite(NULL);
-- 
2.17.1


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

  reply	other threads:[~2018-06-06  7:12 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 ` Sascha Hauer [this message]
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 ` [PATCH 4/6] ppc: bootm: Drop usage of data->oftree Sascha Hauer
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-2-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