Re: [PATCH] cmd: add a panic command

2020-06-29 Thread Simon Glass
On Fri, 26 Jun 2020 at 05:36, Heiko Stuebner  wrote:
>
> From: Heiko Stuebner 
>
> Even in boot scripts it may be needed to "panic" when all options
> are exhausted and the device specification specifies hanging
> instead of resetting the board.
>
> So add a new panic command that just wraps around the core panic
> call in uboot and can take an optional message.

U-Boot

>
> Signed-off-by: Heiko Stuebner 
> ---
>  cmd/Makefile |  1 +
>  cmd/panic.c  | 22 ++
>  2 files changed, 23 insertions(+)
>  create mode 100644 cmd/panic.c

Reviewed-by: Simon Glass 

nit below

>
> diff --git a/cmd/Makefile b/cmd/Makefile
> index ac843b4b16..027fa9083a 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
>  obj-y += boot.o
>  obj-$(CONFIG_CMD_BOOTM) += bootm.o
>  obj-y += help.o
> +obj-y += panic.o
>  obj-y += version.o
>
>  # command
> diff --git a/cmd/panic.c b/cmd/panic.c
> new file mode 100644
> index 00..696b4c73a3
> --- /dev/null
> +++ b/cmd/panic.c
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
> + */
> +
> +#include 
> +#include 
> +
> +static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc,
> +   char * const argv[])
> +{
> +   char *text = (argc < 2) ? "" : argv[1];
> +
> +   panic(text);

blank line here


> +   return CMD_RET_SUCCESS;
> +}
> +
> +U_BOOT_CMD(
> +   panic,  2,  1,  do_panic,
> +   "Panic with optional message",
> +   "[message]"
> +);
> --
> 2.26.2
>


[PATCH] cmd: add a panic command

2020-06-26 Thread Heiko Stuebner
From: Heiko Stuebner 

Even in boot scripts it may be needed to "panic" when all options
are exhausted and the device specification specifies hanging
instead of resetting the board.

So add a new panic command that just wraps around the core panic
call in uboot and can take an optional message.

Signed-off-by: Heiko Stuebner 
---
 cmd/Makefile |  1 +
 cmd/panic.c  | 22 ++
 2 files changed, 23 insertions(+)
 create mode 100644 cmd/panic.c

diff --git a/cmd/Makefile b/cmd/Makefile
index ac843b4b16..027fa9083a 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += boot.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y += help.o
+obj-y += panic.o
 obj-y += version.o
 
 # command
diff --git a/cmd/panic.c b/cmd/panic.c
new file mode 100644
index 00..696b4c73a3
--- /dev/null
+++ b/cmd/panic.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
+ */
+
+#include 
+#include 
+
+static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   char *text = (argc < 2) ? "" : argv[1];
+
+   panic(text);
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+   panic,  2,  1,  do_panic,
+   "Panic with optional message",
+   "[message]"
+);
-- 
2.26.2