[PATCH 31/37] ARM: bootm: rework concatenated oftree

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

 



Without compiled in devicetree support we used to copy the
concatenated devicetree directly behind the zImage. This is
unnecessary, even if we do not have devicetree support we can
copy the devicetree whereever we like and pass the kernel a
pointer to it. This makes the code a bit easier.
While at it, add the missing free calls in the error case.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/lib/bootm.c |   36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 234f3e0..2a7d0f5 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -131,8 +131,6 @@ struct zimage_header {
 static int do_bootz_linux_fdt(int fd, struct image_data *data)
 {
 	struct fdt_header __header, *header;
-	struct resource *r = data->os_res;
-	struct resource *of_res = data->os_res;
 	void *oftree;
 	int ret;
 
@@ -151,21 +149,10 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 
 	end = be32_to_cpu(header->totalsize);
 
-	if (IS_BUILTIN(CONFIG_OFTREE)) {
-		oftree = malloc(end + 0x8000);
-		if (!oftree) {
-			perror("zImage: oftree malloc");
-			return -ENOMEM;
-		}
-	} else {
-
-		of_res = request_sdram_region("oftree", r->start + resource_size(r), end);
-		if (!of_res) {
-			perror("zImage: oftree request_sdram_region");
-			return -ENOMEM;
-		}
-
-		oftree = (void*)of_res->start;
+	oftree = malloc(end + 0x8000);
+	if (!oftree) {
+		perror("zImage: oftree malloc");
+		return -ENOMEM;
 	}
 
 	memcpy(oftree, header, sizeof(*header));
@@ -174,10 +161,11 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 
 	ret = read_full(fd, oftree + sizeof(*header), end);
 	if (ret < 0)
-		return ret;
+		goto err_free;
 	if (ret < end) {
 		printf("premature end of image\n");
-		return -EIO;
+		ret = -EIO;
+		goto err_free;
 	}
 
 	if (IS_BUILTIN(CONFIG_OFTREE)) {
@@ -186,15 +174,23 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 		node = of_unflatten_dtb(NULL, oftree);
 		if (!node) {
 			pr_err("unable to unflatten devicetree\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto err_free;
 		}
 
 		data->oftree = of_get_fixed_tree(node);
+	} else {
+		data->oftree = oftree;
 	}
 
 	pr_info("zImage: concatenated oftree detected\n");
 
 	return 0;
+
+err_free:
+	free(oftree);
+
+	return ret;
 }
 
 static int do_bootz_linux(struct image_data *data)
-- 
1.7.10.4


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


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

  Powered by Linux