mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] boot: make it a little bit less verbose
@ 2019-01-19  0:50 Vivien Didelot
  2019-01-21  8:42 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Vivien Didelot @ 2019-01-19  0:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov, Vivien Didelot

The current boot code prints too much error messages without much value
in them. This patch prints the error string when it makes sense and
simplifies the return path of bootscript_boot(). Make use of pr_err()
in boot_entry() which is the shared code responsible for calling the
boot_entry->boot callback. Remove the unnecessary print statement
from bootsource_action() as well.

This removes a single print statement ATM, allowing us to go from this:

    booting 'sd'
    Cannot set parameter mci0.probe: No such device
    running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed
    could not open /mnt/sd/zImage: No such device
    ERROR: Booting 'sd' failed: No such device
    booting 'sd' failed: No such device
    boot: No such device

to this:

    Booting entry 'sd'
    Cannot set parameter mci0.probe: No such device
    running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed
    could not open /mnt/sd/zImage: No such device
    ERROR: Booting entry 'sd' failed
    boot: No such device

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
---
 common/boot.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/common/boot.c b/common/boot.c
index 41bf1ce64..974eaf5d0 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -96,8 +96,8 @@ static int bootscript_boot(struct bootentry *entry, int verbose, int dryrun)
 
 	ret = run_command(bs->scriptpath);
 	if (ret) {
-		printf("Running %s failed\n", bs->scriptpath);
-		goto out;
+		pr_err("Running script '%s' failed: %s\n", bs->scriptpath, strerror(-ret));
+		return ret;
 	}
 
 	bootm_data_init_defaults(&data);
@@ -107,11 +107,7 @@ static int bootscript_boot(struct bootentry *entry, int verbose, int dryrun)
 	if (dryrun)
 		data.dryrun = dryrun;
 
-	ret = bootm_boot(&data);
-	if (ret)
-		pr_err("Booting '%s' failed: %s\n", basename(bs->scriptpath), strerror(-ret));
-out:
-	return ret;
+	return bootm_boot(&data);
 }
 
 static unsigned int boot_watchdog_timeout;
@@ -135,7 +131,7 @@ int boot_entry(struct bootentry *be, int verbose, int dryrun)
 {
 	int ret;
 
-	printf("booting '%s'\n", be->title);
+	printf("Booting entry '%s'\n", be->title);
 
 	if (IS_ENABLED(CONFIG_WATCHDOG) && boot_watchdog_timeout) {
 		ret = watchdog_set_timeout(boot_watchdog_timeout);
@@ -144,9 +140,8 @@ int boot_entry(struct bootentry *be, int verbose, int dryrun)
 	}
 
 	ret = be->boot(be, verbose, dryrun);
-
 	if (ret)
-		printf("booting '%s' failed: %s\n", be->title, strerror(-ret));
+		pr_err("Booting entry '%s' failed\n", be->title);
 
 	return ret;
 }
@@ -154,11 +149,8 @@ int boot_entry(struct bootentry *be, int verbose, int dryrun)
 static void bootsource_action(struct menu *m, struct menu_entry *me)
 {
 	struct bootentry *be = container_of(me, struct bootentry, me);
-	int ret;
 
-	ret = boot_entry(be, 0, 0);
-	if (ret)
-		printf("Booting failed with: %s\n", strerror(-ret));
+	boot_entry(be, 0, 0);
 
 	printf("Press any key to continue\n");
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] boot: make it a little bit less verbose
  2019-01-19  0:50 [PATCH] boot: make it a little bit less verbose Vivien Didelot
@ 2019-01-21  8:42 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-01-21  8:42 UTC (permalink / raw)
  To: Vivien Didelot; +Cc: Andrey Smirnov, barebox

On Fri, Jan 18, 2019 at 07:50:51PM -0500, Vivien Didelot wrote:
> The current boot code prints too much error messages without much value
> in them. This patch prints the error string when it makes sense and
> simplifies the return path of bootscript_boot(). Make use of pr_err()
> in boot_entry() which is the shared code responsible for calling the
> boot_entry->boot callback. Remove the unnecessary print statement
> from bootsource_action() as well.
> 
> This removes a single print statement ATM, allowing us to go from this:
> 
>     booting 'sd'
>     Cannot set parameter mci0.probe: No such device
>     running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed
>     could not open /mnt/sd/zImage: No such device
>     ERROR: Booting 'sd' failed: No such device
>     booting 'sd' failed: No such device
>     boot: No such device
> 
> to this:
> 
>     Booting entry 'sd'
>     Cannot set parameter mci0.probe: No such device
>     running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed
>     could not open /mnt/sd/zImage: No such device
>     ERROR: Booting entry 'sd' failed
>     boot: No such device
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
> ---
>  common/boot.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)

Yeah, looks better.

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-21  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-19  0:50 [PATCH] boot: make it a little bit less verbose Vivien Didelot
2019-01-21  8:42 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox