All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Opaniuk <igor.opaniuk@toradex.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’
Date: Thu, 7 Mar 2019 05:08:44 +0000	[thread overview]
Message-ID: <CAModR+WwxmeFS6x0O-GJqMc96kYXnuiYjFx2YMdQW3JFdBqbSw@mail.gmail.com> (raw)
In-Reply-To: <20190201151852.13064-2-marcel@ziswiler.com>

Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>

On Fri, 1 Feb 2019 at 17:24, Marcel Ziswiler <marcel@ziswiler.com> wrote:
>
> From: Dominik Sliwa <dominik.sliwa@toradex.com>
>
> Add an optional -y parameter to 'cfgblock create’ to simplify
> automation.
>
> Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
> Acked-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>
> ---
>
>  board/toradex/common/tdx-cfg-block.c | 39 ++++++++++++++++++----------
>  1 file changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
> index d4f5b1803a..2fcb998ae4 100644
> --- a/board/toradex/common/tdx-cfg-block.c
> +++ b/board/toradex/common/tdx-cfg-block.c
> @@ -418,6 +418,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
>         int offset = 0;
>         int ret = CMD_RET_SUCCESS;
>         int err;
> +       int force_overwrite = 0;
>
>         /* Allocate RAM area for config block */
>         config_block = memalign(ARCH_DMA_MINALIGN, size);
> @@ -428,6 +429,11 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
>
>         memset(config_block, 0xff, size);
>
> +       if (argc >= 3) {
> +               if (argv[2][0] == '-' && argv[2][1] == 'y')
> +                       force_overwrite = 1;
> +       }
> +
>         read_tdx_cfg_block();
>         if (valid_cfgblock) {
>  #if defined(CONFIG_TDX_CFG_BLOCK_IS_IN_NAND)
> @@ -448,24 +454,31 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
>                        CONFIG_TDX_CFG_BLOCK_OFFSET);
>                 goto out;
>  #else
> -               char message[CONFIG_SYS_CBSIZE];
> -               sprintf(message,
> -                       "A valid Toradex config block is present, still recreate? [y/N] ");
> +               if (!force_overwrite) {
> +                       char message[CONFIG_SYS_CBSIZE];
>
> -               if (!cli_readline(message))
> -                       goto out;
> +                       sprintf(message,
> +                               "A valid Toradex config block is present, still recreate? [y/N] ");
>
> -               if (console_buffer[0] != 'y' && console_buffer[0] != 'Y')
> -                       goto out;
> +                       if (!cli_readline(message))
> +                               goto out;
> +
> +                       if (console_buffer[0] != 'y' &&
> +                           console_buffer[0] != 'Y')
> +                               goto out;
> +               }
>  #endif
>         }
>
>         /* Parse new Toradex config block data... */
> -       if (argc < 3)
> +       if (argc < 3 || (force_overwrite && argc < 4)) {
>                 err = get_cfgblock_interactive();
> -       else
> -               err = get_cfgblock_barcode(argv[2]);
> -
> +       } else {
> +               if (force_overwrite)
> +                       err = get_cfgblock_barcode(argv[3]);
> +               else
> +                       err = get_cfgblock_barcode(argv[2]);
> +       }
>         if (err) {
>                 ret = CMD_RET_FAILURE;
>                 goto out;
> @@ -549,8 +562,8 @@ static int do_cfgblock(cmd_tbl_t *cmdtp, int flag, int argc,
>  }
>
>  U_BOOT_CMD(
> -       cfgblock, 3, 0, do_cfgblock,
> +       cfgblock, 4, 0, do_cfgblock,
>         "Toradex config block handling commands",
> -       "create [barcode] - (Re-)create Toradex config block\n"
> +       "create [-y] [barcode] - (Re-)create Toradex config block\n"
>         "cfgblock reload - Reload Toradex config block from flash"
>  );
> --
> 2.20.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

  reply	other threads:[~2019-03-07  5:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 15:18 [U-Boot] [PATCH v1 0/3] toradex: common: fix/improve config block handling Marcel Ziswiler
2019-02-01 15:18 ` [U-Boot] [PATCH v1 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’ Marcel Ziswiler
2019-03-07  5:08   ` Igor Opaniuk [this message]
2019-02-01 15:18 ` [U-Boot] [PATCH v1 2/3] toradex: common: unify behaviour when config block is missing Marcel Ziswiler
2019-03-07  5:21   ` Igor Opaniuk
2019-02-01 15:18 ` [U-Boot] [PATCH v1 3/3] tdx-cfg-block: fix off by one issue Marcel Ziswiler
2019-03-07  5:24   ` Igor Opaniuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAModR+WwxmeFS6x0O-GJqMc96kYXnuiYjFx2YMdQW3JFdBqbSw@mail.gmail.com \
    --to=igor.opaniuk@toradex.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.