autostart: unify duplicated logic into the bootm code
PATCH 1/1 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.
--- common/cmd_bootm.c | 15 +++++++++++++++ common/cmd_fdc.c | 15 +-------------- common/cmd_fdos.c | 11 +---------- common/cmd_ide.c | 15 +-------------- common/cmd_nand.c | 14 +------------- common/cmd_net.c | 13 ++----------- common/cmd_scsi.c | 11 +---------- common/cmd_usb.c | 13 ++----------- include/command.h | 8 ++++++++ 9 files changed, 32 insertions(+), 83 deletions(-)
common/cmd_bootm.c +15 -0
@@ -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 *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
common/cmd_fdc.c +1 -14
@@ -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(
common/cmd_fdos.c +1 -10
@@ -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 ]); }/*-----------------------------------------------------------------------------
common/cmd_ide.c +1 -14
@@ -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 ]); }/* ------------------------------------------------------------------------- */
common/cmd_nand.c +1 -13
@@ -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[])
common/cmd_net.c +2 -11
@@ -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 );
common/cmd_scsi.c +1 -10
@@ -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 ]); }/*********************************************************************************
common/cmd_usb.c +2 -11
@@ -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@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 */
include/command.h +8 -0
@@ -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__ */
Signature · 1 line
1.7.5.3
PATCH 1/1 autostart: unify duplicated logic into the bootm code
Quoted 18 lines · Mike Frysinger
common/cmd_usb.c +1
-2@@ -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 */
common/cmd_usb.c int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 493
Quoted 10 lines
common/cmd_usb.c +1
-9- ? ? ? 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]);
Typo here... need bootm_maybe_autostart
-M
PATCH v2 1/1 autostart: unify duplicated logic into the bootm code
In reply to Mike FrysingerRather 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.
---
v2
- fix usb typo pointed out by Matthew
common/cmd_bootm.c | 15 +++++++++++++++ common/cmd_fdc.c | 15 +-------------- common/cmd_fdos.c | 11 +---------- common/cmd_ide.c | 15 +-------------- common/cmd_nand.c | 14 +------------- common/cmd_net.c | 13 ++----------- common/cmd_scsi.c | 11 +---------- common/cmd_usb.c | 13 ++----------- include/command.h | 8 ++++++++ 9 files changed, 32 insertions(+), 83 deletions(-)
common/cmd_bootm.c +15 -0
@@ -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 *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
common/cmd_fdc.c +1 -14
@@ -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(
common/cmd_fdos.c +1 -10
@@ -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 ]); }/*-----------------------------------------------------------------------------
common/cmd_ide.c +1 -14
@@ -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 ]); }/* ------------------------------------------------------------------------- */
common/cmd_nand.c +1 -13
@@ -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[])
common/cmd_net.c +2 -11
@@ -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 );
common/cmd_scsi.c +1 -10
@@ -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 ]); }/*********************************************************************************
common/cmd_usb.c +2 -11
@@ -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@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 */
include/command.h +8 -0
@@ -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__ */
Signature · 1 line
1.7.5.3
PATCH v3 1/1 autostart: unify duplicated logic into the bootm code
In reply to Mike FrysingerRather 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.
---
v3
- fix unused warnings arising from variables no longer being used
common/cmd_bootm.c | 15 +++++++++++++++ common/cmd_fdc.c | 16 +--------------- common/cmd_fdos.c | 11 +---------- common/cmd_ide.c | 15 +-------------- common/cmd_nand.c | 16 ++-------------- common/cmd_net.c | 13 ++----------- common/cmd_scsi.c | 11 +---------- common/cmd_usb.c | 13 ++----------- include/command.h | 8 ++++++++ 9 files changed, 33 insertions(+), 85 deletions(-)
common/cmd_bootm.c +15 -0
@@ -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 *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
common/cmd_fdc.c +1 -15
@@ -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(
common/cmd_fdos.c +1 -10
@@ -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 ]); }/*-----------------------------------------------------------------------------
common/cmd_ide.c +1 -14
@@ -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 ]); }/* ------------------------------------------------------------------------- */
common/cmd_nand.c +2 -14
@@ -724,7 +724,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 )
@@ -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[])
common/cmd_net.c +2 -11
@@ -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 );
common/cmd_scsi.c +1 -10
@@ -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 ]); }/*********************************************************************************
common/cmd_usb.c +2 -11
@@ -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@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 */
include/command.h +8 -0
@@ -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__ */
Signature · 1 line
1.7.5.3
Wolfgang Denk
AppliedPATCH v3 1/1 autostart: unify duplicated logic into the bootm code
Dear Mike Frysinger,
Quoted 11 lines · In message <[email protected]> you wrote:
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 Scott Wood <[email protected]>Signed-off-by Mike Frysinger <[email protected]>---
v3
- fix unused warnings arising from variables no longer being used
Quoted 10 lines
common/cmd_bootm.c | 15 +++++++++++++++ common/cmd_fdc.c | 16 +--------------- common/cmd_fdos.c | 11 +---------- common/cmd_ide.c | 15 +-------------- common/cmd_nand.c | 16 ++-------------- common/cmd_net.c | 13 ++----------- common/cmd_scsi.c | 11 +---------- common/cmd_usb.c | 13 ++----------- include/command.h | 8 ++++++++ 9 files changed, 33 insertions(+), 85 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Uncontrolled power will turn even saints into savages. And we can all be counted on to live down to our lowest impulses. -- Parmen, "Plato's Stepchildren", stardate 5784.3