From patchwork Wed Jun 1 15:10:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 98207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id F0F60B6F7E for ; Thu, 2 Jun 2011 01:11:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C44BB28155; Wed, 1 Jun 2011 17:11:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8qDEZgXIDbfF; Wed, 1 Jun 2011 17:11:01 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F2C128135; Wed, 1 Jun 2011 17:11:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5B2F928135 for ; Wed, 1 Jun 2011 17:10:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mygaK3jEF80I for ; Wed, 1 Jun 2011 17:10:57 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 12DA9280E3 for ; Wed, 1 Jun 2011 17:10:56 +0200 (CEST) Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 85EE964210; Wed, 1 Jun 2011 15:10:50 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: Matthew McClintock Date: Wed, 1 Jun 2011 11:10:49 -0400 User-Agent: KMail/1.13.7 (Linux/2.6.39; KDE/4.6.3; x86_64; ; ) References: <201105232312.53322.vapier@gentoo.org> <1306252059-26770-1-git-send-email-msm@freescale.com> In-Reply-To: <1306252059-26770-1-git-send-email-msm@freescale.com> MIME-Version: 1.0 Message-Id: <201106011110.50651.vapier@gentoo.org> Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2 2/3] common/cmd_nand.c: add ifdef protection for do_bootm X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On Tuesday, May 24, 2011 11:47:39 Matthew McClintock wrote: > Right now we do not check if do_bootm is actually built into this > u-boot. Instead check define and only call do_bootm if it's actually > available. actually, if you dont mind, i'd like to obsolete this patch with the one below. what do you think ? -mike diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 18019d6..c5c169f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -707,6 +707,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 * const local_args[2]; + local_args[0] = cmd; + local_args[1] = NULL; + printf("Automatic boot of image at addr 0x%08lX ...\n", 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 cdb050c..20ebf6c 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -722,7 +722,6 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned char boot_drive; int i,nrofblk; char *ep; - int rcode = 0; #if defined(CONFIG_FIT) const void *fit_hdr = NULL; #endif @@ -823,19 +822,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 2af4ca0..d714af8 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 a1f7e57..07890e7 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 7bd37de..92ae186 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -799,19 +799,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 8c6f5c8..322839a 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -210,17 +210,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 be4fe74..8019ada 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 b5731a7..efec895 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 maybe_autostart(cmdtp, argv[0]); } #endif /* CONFIG_USB_STORAGE */ diff --git a/include/command.h b/include/command.h index cab9651..f1accd0 100644 --- a/include/command.h +++ b/include/command.h @@ -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_BOOTM 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__ */