diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-08 08:28:07 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-12-08 08:28:07 +0100 |
commit | 24f1c994cc7ae61e3eee1b34b114315833a4186f (patch) | |
tree | abc3a4e6010cf15377bd72303e837d8a5b4f8912 /common | |
parent | 3cdcff497976a60ccbef37c67713c3acea0d35eb (diff) | |
parent | b734bb97a22f1c3e96f10eb235050808f661778b (diff) | |
download | barebox-24f1c994cc7ae61e3eee1b34b114315833a4186f.tar.gz barebox-24f1c994cc7ae61e3eee1b34b114315833a4186f.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/bootm.c | 103 | ||||
-rw-r--r-- | common/environment.c | 12 | ||||
-rw-r--r-- | common/state.c | 2 |
3 files changed, 75 insertions, 42 deletions
diff --git a/common/bootm.c b/common/bootm.c index 447c9b624c..08125e7bb0 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -245,25 +245,19 @@ static int bootm_open_initrd_uimage(struct image_data *data) return 0; } -static int bootm_open_oftree(struct image_data *data, const char *oftree, int num) +static int bootm_open_oftree_uimage(struct image_data *data) { - enum filetype ft; struct fdt_header *fdt; + enum filetype ft; + const char *oftree = data->oftree_file; + int num = data->oftree_num; + struct uimage_handle *of_handle; + int release = 0; size_t size; - printf("Loading devicetree from '%s'\n", oftree); - - ft = file_name_detect_type(oftree); - if ((int)ft < 0) { - printf("failed to open %s: %s\n", oftree, strerror(-(int)ft)); - return ft; - } - - if (ft == filetype_uimage) { -#ifdef CONFIG_CMD_BOOTM_OFTREE_UIMAGE - struct uimage_handle *of_handle; - int release = 0; + printf("Loading devicetree from '%s'@%d\n", oftree, num); + if (IS_ENABLED(CONFIG_CMD_BOOTM_OFTREE_UIMAGE)) { if (!strcmp(data->os_file, oftree)) { of_handle = data->os; } else if (!strcmp(data->initrd_file, oftree)) { @@ -280,23 +274,42 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu if (release) uimage_close(of_handle); -#else - return -EINVAL; -#endif - } else { - fdt = read_file(oftree, &size); - if (!fdt) { - perror("open"); - return -ENODEV; + + ft = file_detect_type(fdt, size); + if (ft != filetype_oftree) { + printf("%s is not an oftree but %s\n", + data->oftree_file, file_type_to_string(ft)); + return -EINVAL; } - } - ft = file_detect_type(fdt, size); - if (ft != filetype_oftree) { - printf("%s is not an oftree but %s\n", oftree, - file_type_to_string(ft)); + data->of_root_node = of_unflatten_dtb(fdt); + if (!data->of_root_node) { + pr_err("unable to unflatten devicetree\n"); + free(fdt); + return -EINVAL; + } + + free(fdt); + + return 0; + } else { return -EINVAL; } +} + +static int bootm_open_oftree(struct image_data *data) +{ + struct fdt_header *fdt; + const char *oftree = data->oftree_file; + size_t size; + + printf("Loading devicetree from '%s'\n", oftree); + + fdt = read_file(oftree, &size); + if (!fdt) { + perror("open"); + return -ENODEV; + } data->of_root_node = of_unflatten_dtb(fdt); if (!data->of_root_node) { @@ -368,6 +381,7 @@ int bootm_boot(struct bootm_data *bootm_data) struct image_handler *handler; int ret; enum filetype os_type, initrd_type = filetype_unknown; + enum filetype oftree_type = filetype_unknown; if (!bootm_data->os_file) { printf("no image given\n"); @@ -401,6 +415,28 @@ int bootm_boot(struct bootm_data *bootm_data) goto err_out; } + if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && data->initrd_file) { + initrd_type = file_name_detect_type(data->initrd_file); + + if ((int)initrd_type < 0) { + printf("could not open %s: %s\n", data->initrd_file, + strerror(-initrd_type)); + ret = (int)initrd_type; + goto err_out; + } + } + + if (IS_ENABLED(CONFIG_OFTREE) && data->oftree_file) { + oftree_type = file_name_detect_type(data->oftree_file); + + if ((int)oftree_type < 0) { + printf("could not open %s: %s\n", data->oftree_file, + strerror(-oftree_type)); + ret = (int) oftree_type; + goto err_out; + } + } + if (os_type == filetype_uimage) { ret = bootm_open_os_uimage(data); if (ret) { @@ -411,14 +447,6 @@ int bootm_boot(struct bootm_data *bootm_data) } if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && data->initrd_file) { - - initrd_type = file_name_detect_type(data->initrd_file); - if ((int)initrd_type < 0) { - printf("could not open %s: %s\n", data->initrd_file, - strerror(-initrd_type)); - ret = (int)initrd_type; - goto err_out; - } if (initrd_type == filetype_uimage) { ret = bootm_open_initrd_uimage(data); if (ret) { @@ -438,7 +466,10 @@ int bootm_boot(struct bootm_data *bootm_data) if (IS_ENABLED(CONFIG_OFTREE)) { if (data->oftree_file) { - ret = bootm_open_oftree(data, data->oftree_file, data->oftree_num); + if (oftree_type == filetype_uimage) + ret = bootm_open_oftree_uimage(data); + if (oftree_type == filetype_oftree) + ret = bootm_open_oftree(data); if (ret) goto err_out; } else { diff --git a/common/environment.c b/common/environment.c index f6fd781a8a..f412e62258 100644 --- a/common/environment.c +++ b/common/environment.c @@ -324,16 +324,16 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) ret = protect(envfd, ~0, 0, 0); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not unprotect %s: %s\n", filename, errno_str()); goto out; } ret = erase(envfd, ~0, 0); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not erase %s: %s\n", filename, errno_str()); goto out; } @@ -355,8 +355,8 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) ret = protect(envfd, ~0, 0, 1); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not protect %s: %s\n", filename, errno_str()); goto out; } diff --git a/common/state.c b/common/state.c index 117a686759..a161b94f3a 100644 --- a/common/state.c +++ b/common/state.c @@ -716,6 +716,8 @@ static int state_convert_node_variable(struct state *state, vtype = state_find_type_by_name(type_name); if (!vtype) { + dev_err(&state->dev, "unkown type: %s in %s\n", type_name, + node->full_name); ret = -ENOENT; goto out_free; } |