diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-01-15 12:57:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-01-26 22:45:40 +0100 |
commit | bc94fb379a46f9b4dabc982953a8d553c909bedb (patch) | |
tree | 7e1dff5e7d4f26f92bbf40ebb531a982d58dcde6 /commands/bootm.c | |
parent | a8531386ffdd3f0327bcd22a4b1447477453ad26 (diff) | |
download | barebox-bc94fb379a46f9b4dabc982953a8d553c909bedb.tar.gz barebox-bc94fb379a46f9b4dabc982953a8d553c909bedb.tar.xz |
bootm: Initialize bootm_data defaults in single place
Both the bootm and the boot code initialize the struct bootm_data
with defaults from the bootm global variables. Create a common
function for doing this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/bootm.c')
-rw-r--r-- | commands/bootm.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/commands/bootm.c b/commands/bootm.c index 063da62177..6db0e6596e 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -59,19 +59,8 @@ static int do_bootm(int argc, char *argv[]) int opt; struct bootm_data data = {}; int ret = 1; - const char *oftree = NULL, *initrd_file = NULL, *os_file = NULL; - data.initrd_address = UIMAGE_INVALID_ADDRESS; - data.os_address = UIMAGE_SOME_ADDRESS; - data.verify = 0; - data.verbose = 0; - - oftree = getenv("global.bootm.oftree"); - os_file = getenv("global.bootm.image"); - getenv_ul("global.bootm.image.loadaddr", &data.os_address); - getenv_ul("global.bootm.initrd.loadaddr", &data.initrd_address); - if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD)) - initrd_file = getenv("global.bootm.initrd"); + bootm_data_init_defaults(&data); while ((opt = getopt(argc, argv, BOOTM_OPTS)) > 0) { switch(opt) { @@ -83,7 +72,7 @@ static int do_bootm(int argc, char *argv[]) data.initrd_address = simple_strtoul(optarg, NULL, 0); break; case 'r': - initrd_file = optarg; + data.initrd_file = optarg; break; #endif case 'a': @@ -96,7 +85,7 @@ static int do_bootm(int argc, char *argv[]) data.verbose++; break; case 'o': - oftree = optarg; + data.oftree_file = optarg; break; case 'f': data.force = 1; @@ -110,23 +99,13 @@ static int do_bootm(int argc, char *argv[]) } if (optind != argc) - os_file = argv[optind]; + data.os_file = argv[optind]; - if (!os_file || !*os_file) { + if (!data.os_file) { printf("no boot image given\n"); goto err_out; } - if (initrd_file && !*initrd_file) - initrd_file = NULL; - - if (oftree && !*oftree) - oftree = NULL; - - data.os_file = os_file; - data.oftree_file = oftree; - data.initrd_file = initrd_file; - ret = bootm_boot(&data); if (ret) { printf("handler failed with: %s\n", strerror(-ret)); |