summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-12-06 08:44:05 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-12-07 17:47:43 +0100
commit3180d4b3e321b827ecf6851853ef67531b84eff7 (patch)
tree488da213edd9bdc6ab0fec1100da8a5ef049468b
parent083b3bd52aaaa20d90c825d8b606280e977a51de (diff)
downloadbarebox-3180d4b3e321b827ecf6851853ef67531b84eff7.tar.gz
barebox-3180d4b3e321b827ecf6851853ef67531b84eff7.tar.xz
bootm: factor out initrd code from option parser
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--commands/bootm.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/commands/bootm.c b/commands/bootm.c
index 859ec28a26..f97a842232 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -121,6 +121,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
struct image_handle *os_handle = NULL;
struct image_handler *handler;
struct image_data data;
+ const char *initrdname = NULL;
int ret = 1;
memset(&data, 0, sizeof(struct image_data));
@@ -136,17 +137,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
data.initrd_address = simple_strtoul(optarg, NULL, 0);
break;
case 'r':
- printf("use initrd %s\n", optarg);
- /* check for multi image @<num> */
- if (optarg[0] == '@') {
- int num = simple_strtol(optarg + 1, NULL, 0);
-
- data.initrd = get_fake_image_handle(&data, num);
- } else {
- data.initrd = map_image(optarg, data.verify);
- }
- if (!data.initrd)
- goto err_out;
+ initrdname = optarg;
break;
default:
break;
@@ -171,6 +162,19 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
goto err_out;
}
+ if (initrdname) {
+ /* check for multi image @<num> */
+ if (initrdname[0] == '@') {
+ int num = simple_strtol(optarg + 1, NULL, 0);
+
+ data.initrd = get_fake_image_handle(&data, num);
+ } else {
+ data.initrd = map_image(optarg, data.verify);
+ }
+ if (!data.initrd)
+ goto err_out;
+ }
+
/*
* We have reached the point of no return: we are going to
* overwrite all exception vector code, so we cannot easily