]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
autostart: unify duplicated logic into the bootm code
authorMike Frysinger <vapier@gentoo.org>
Sun, 5 Jun 2011 13:43:02 +0000 (13:43 +0000)
committerWolfgang Denk <wd@denx.de>
Mon, 25 Jul 2011 20:18:26 +0000 (22:18 +0200)
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>
common/cmd_bootm.c
common/cmd_fdc.c
common/cmd_fdos.c
common/cmd_ide.c
common/cmd_nand.c
common/cmd_net.c
common/cmd_scsi.c
common/cmd_usb.c
include/command.h

index 1966da48ca49ea1a250b429b1a11a6d76bac2e5d..272d879bebc2036a244794e6631da9cf3dc551cc 100644 (file)
@@ -708,6 +708,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 1;
 }
 
        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
 /**
  * image_get_kernel - verify legacy format kernel image
  * @img_addr: in RAM address of the legacy format image to be verified
index cdb050c255980577d460b4e2da15c5b30e804a2f..40d12f68829d5ce3c584d4918f9876d739b9e5a2 100644 (file)
@@ -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;
        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
 #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;
 
        /* 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(
 }
 
 U_BOOT_CMD(
index 2af4ca0efeb788707b6f40583026767a8f05cf50..d714af8db9f970a5a9c298f6eb4dae48226fdf71 100644 (file)
@@ -40,7 +40,6 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
     char *name;
     char *ep;
     int size;
     char *name;
     char *ep;
     int size;
-    int rcode = 0;
     char buf [12];
     int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
 
     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);
 
     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]);
 }
 
 /*-----------------------------------------------------------------------------
 }
 
 /*-----------------------------------------------------------------------------
index 21fe1eabadb5c4d2ba4fc3746e463388cd6efca6..7fbc05331001569bef457ddcd594d713718c8c0e 100644 (file)
@@ -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;
        ulong addr, cnt;
        disk_partition_t info;
        image_header_t *hdr;
-       int rcode = 0;
 #if defined(CONFIG_FIT)
        const void *fit_hdr = NULL;
 #endif
 #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;
 
 
        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]);
 }
 
 /* ------------------------------------------------------------------------- */
 }
 
 /* ------------------------------------------------------------------------- */
index b767cd287734b7289c79807ada9f157e5fa657cc..66e06a5e39497cbeaf66cb18d29e4f1fb3145291 100644 (file)
@@ -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;
                           ulong offset, ulong addr, char *cmd)
 {
        int r;
-       char *ep, *s;
+       char *s;
        size_t cnt;
        image_header_t *hdr;
 #if defined(CONFIG_FIT)
        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;
 
 
        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[])
 }
 
 int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
index 75ba1c3cdcece26a8cbf918255918a49cf71f689..872f4a69c827f1e15ad448596bce10ea412ddc04 100644 (file)
@@ -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);
 
        /* 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);
 
        if (rcode < 0)
                show_boot_progress (-83);
index be4fe741c3f6ea0bfa390f6aab1f67bf1f96a293..8019adabfc45010f840a3299c7dc2cbb0de35e63 100644 (file)
@@ -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;
        ulong addr, cnt;
        disk_partition_t info;
        image_header_t *hdr;
-       int rcode = 0;
 #if defined(CONFIG_FIT)
        const void *fit_hdr = NULL;
 #endif
 #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);
 
 
        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]);
 }
 
 /*********************************************************************************
 }
 
 /*********************************************************************************
index 3ba6fff4fd325f7e83605a4d0313fa803ad27133..cd4d41725063371e9addb9e9e47d12b12cab1134 100644 (file)
@@ -356,7 +356,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        char *boot_device = NULL;
        char *ep;
 {
        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;
        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);
 
 
        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 */
 
 }
 #endif /* CONFIG_USB_STORAGE */
 
index 8310fe57a5f6d83a44a1f24642941e7d16072cfd..37e118c94ae99f1e98290e974c6d820c726196d8 100644 (file)
@@ -98,7 +98,15 @@ extern int cmd_get_data_size(char* arg, int default_size);
 #ifdef CONFIG_CMD_BOOTD
 extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif
 #ifdef CONFIG_CMD_BOOTD
 extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif
+#ifdef CONFIG_CMD_BOOTM
 extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd);
+#else
+static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
+{
+       return 0;
+}
+#endif
 extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __ASSEMBLY__ */
 extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __ASSEMBLY__ */