summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-03-02 18:15:20 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-06 11:41:29 +0100
commit8f458074e7ab270271a7caa48d81e4980fef5f34 (patch)
tree18f2f3dd0f1ab0cb76d631653e2b5d7c2de3b05c /arch/arm/lib/bootm.c
parent5d6c8ac4b41b66cc2785d4e4e82397a5c7e66336 (diff)
downloadbarebox-8f458074e7ab270271a7caa48d81e4980fef5f34.tar.gz
barebox-8f458074e7ab270271a7caa48d81e4980fef5f34.tar.xz
ARM: bootm: rework concatenated oftree
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@pengutronix.de>
Diffstat (limited to 'arch/arm/lib/bootm.c')
-rw-r--r--arch/arm/lib/bootm.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 234f3e09f1..2a7d0f58f2 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)