summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-06-05 13:43:02 +0000
committerWolfgang Denk <wd@denx.de>2011-07-25 22:18:26 +0200
commit67d668bf926ae50a1196a8561ae5075fd69a8eb2 (patch)
treea5f7e905a55b5f32718a1d1ac7616e9eb995e9be /common
parent51f924e5ce4f69659ef385739f4604054d9b5bb7 (diff)
autostart: unify duplicated logic into the bootm code
Rather than having a bunch of random commands handle autostart behavior, unify the logic in a single place. This also fixes building of these different commands when bootm is disabled. Acked-by: Matthew McClintock <msm@freescale.com> Acked-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bootm.c15
-rw-r--r--common/cmd_fdc.c16
-rw-r--r--common/cmd_fdos.c11
-rw-r--r--common/cmd_ide.c15
-rw-r--r--common/cmd_nand.c16
-rw-r--r--common/cmd_net.c13
-rw-r--r--common/cmd_scsi.c11
-rw-r--r--common/cmd_usb.c13
8 files changed, 25 insertions, 85 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 1966da48ca4..272d879bebc 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -708,6 +708,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
+int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
+{
+ const char *ep = getenv("autostart");
+
+ if (ep && !strcmp(ep, "yes")) {
+ char *local_args[2];
+ local_args[0] = (char *)cmd;
+ local_args[1] = NULL;
+ printf("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
+ return do_bootm(cmdtp, 0, 1, local_args);
+ }
+
+ return 0;
+}
+
/**
* image_get_kernel - verify legacy format kernel image
* @img_addr: in RAM address of the legacy format image to be verified
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c
index cdb050c2559..40d12f68829 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -721,8 +721,6 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
image_header_t *hdr; /* used for fdc boot */
unsigned char boot_drive;
int i,nrofblk;
- char *ep;
- int rcode = 0;
#if defined(CONFIG_FIT)
const void *fit_hdr = NULL;
#endif
@@ -823,19 +821,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Loading ok, update default load address */
load_addr = addr;
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
- char *local_args[2];
-
- local_args[0] = argv[0];
- local_args[1] = NULL;
-
- printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
-
- do_bootm (cmdtp, 0, 1, local_args);
- rcode ++;
- }
- return rcode;
+ return bootm_maybe_autostart(cmdtp, argv[0]);
}
U_BOOT_CMD(
diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c
index 2af4ca0efeb..d714af8db9f 100644
--- a/common/cmd_fdos.c
+++ b/common/cmd_fdos.c
@@ -40,7 +40,6 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char *name;
char *ep;
int size;
- int rcode = 0;
char buf [12];
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
@@ -98,15 +97,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
size, load_addr);
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
- char *local_args[2];
- local_args[0] = argv[0];
- local_args[1] = NULL;
- printf ("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
- rcode = do_bootm (cmdtp, 0, 1, local_args);
- }
- return rcode;
+ return bootm_maybe_autostart(cmdtp, argv[0]);
}
/*-----------------------------------------------------------------------------
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 21fe1eabadb..7fbc0533100 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -356,7 +356,6 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong addr, cnt;
disk_partition_t info;
image_header_t *hdr;
- int rcode = 0;
#if defined(CONFIG_FIT)
const void *fit_hdr = NULL;
#endif
@@ -495,19 +494,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
load_addr = addr;
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
- char *local_args[2];
-
- local_args[0] = argv[0];
- local_args[1] = NULL;
-
- printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
-
- do_bootm (cmdtp, 0, 1, local_args);
- rcode = 1;
- }
- return rcode;
+ return bootm_maybe_autostart(cmdtp, argv[0]);
}
/* ------------------------------------------------------------------------- */
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index b767cd28773..66e06a5e394 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -741,7 +741,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
ulong offset, ulong addr, char *cmd)
{
int r;
- char *ep, *s;
+ char *s;
size_t cnt;
image_header_t *hdr;
#if defined(CONFIG_FIT)
@@ -816,19 +816,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
load_addr = addr;
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
- char *local_args[2];
-
- local_args[0] = cmd;
- local_args[1] = NULL;
-
- printf("Automatic boot of image at addr 0x%08lx ...\n", addr);
-
- do_bootm(cmdtp, 0, 1, local_args);
- return 1;
- }
- return 0;
+ return bootm_maybe_autostart(cmdtp, cmd);
}
int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 75ba1c3cdce..872f4a69c82 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -227,17 +227,8 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[])
/* flush cache */
flush_cache(load_addr, size);
- /* Loading ok, check if we should attempt an auto-start */
- if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) {
- char *local_args[2];
- local_args[0] = argv[0];
- local_args[1] = NULL;
-
- printf ("Automatic boot of image at addr 0x%08lX ...\n",
- load_addr);
- show_boot_progress (82);
- rcode = do_bootm (cmdtp, 0, 1, local_args);
- }
+ show_boot_progress(82);
+ rcode = bootm_maybe_autostart(cmdtp, argv[0]);
if (rcode < 0)
show_boot_progress (-83);
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index be4fe741c3f..8019adabfc4 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -210,7 +210,6 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong addr, cnt;
disk_partition_t info;
image_header_t *hdr;
- int rcode = 0;
#if defined(CONFIG_FIT)
const void *fit_hdr = NULL;
#endif
@@ -326,15 +325,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
flush_cache (addr, (cnt+1)*info.blksz);
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
- char *local_args[2];
- local_args[0] = argv[0];
- local_args[1] = NULL;
- printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
- rcode = do_bootm (cmdtp, 0, 1, local_args);
- }
- return rcode;
+ return bootm_maybe_autostart(cmdtp, argv[0]);
}
/*********************************************************************************
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 3ba6fff4fd3..cd4d4172506 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -356,7 +356,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *boot_device = NULL;
char *ep;
- int dev, part = 1, rcode;
+ int dev, part = 1;
ulong addr, cnt;
disk_partition_t info;
image_header_t *hdr;
@@ -490,16 +490,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
flush_cache(addr, (cnt+1)*info.blksz);
- /* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
- char *local_args[2];
- local_args[0] = argv[0];
- local_args[1] = NULL;
- printf("Automatic boot of image at addr 0x%08lX ...\n", addr);
- rcode = do_bootm(cmdtp, 0, 1, local_args);
- return rcode;
- }
- return 0;
+ return bootm_maybe_autostart(cmdtp, argv[0]);
}
#endif /* CONFIG_USB_STORAGE */