From: Marcel Ziswiler Date: Fri, 1 Feb 2019 16:18:50 +0100 Subject: [U-Boot] =?utf-8?q?=5BPATCH_v1_1/3=5D_toradex=3A_configblock=3A_a?= =?utf-8?q?dd_an_-y_parameter_to_=27cfgblock_create=E2=80=99?= In-Reply-To: <20190201151852.13064-1-marcel@ziswiler.com> References: <20190201151852.13064-1-marcel@ziswiler.com> Message-ID: <20190201151852.13064-2-marcel@ziswiler.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de From: Dominik Sliwa Add an optional -y parameter to 'cfgblock create=E2=80=99 to simplify automation. Signed-off-by: Dominik Sliwa Acked-by: Stefan Agner Acked-by: Marcel Ziswiler --- 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/td= x-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 fla= g, int argc, int offset =3D 0; int ret =3D CMD_RET_SUCCESS; int err; + int force_overwrite =3D 0; =20 /* Allocate RAM area for config block */ config_block =3D memalign(ARCH_DMA_MINALIGN, size); @@ -428,6 +429,11 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int fl= ag, int argc, =20 memset(config_block, 0xff, size); =20 + if (argc >=3D 3) { + if (argv[2][0] =3D=3D '-' && argv[2][1] =3D=3D 'y') + force_overwrite =3D 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 f= lag, 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]; =20 - if (!cli_readline(message)) - goto out; + sprintf(message, + "A valid Toradex config block is present, still recreate? [y/N] "); =20 - if (console_buffer[0] !=3D 'y' && console_buffer[0] !=3D 'Y') - goto out; + if (!cli_readline(message)) + goto out; + + if (console_buffer[0] !=3D 'y' && + console_buffer[0] !=3D 'Y') + goto out; + } #endif } =20 /* Parse new Toradex config block data... */ - if (argc < 3) + if (argc < 3 || (force_overwrite && argc < 4)) { err =3D get_cfgblock_interactive(); - else - err =3D get_cfgblock_barcode(argv[2]); - + } else { + if (force_overwrite) + err =3D get_cfgblock_barcode(argv[3]); + else + err =3D get_cfgblock_barcode(argv[2]); + } if (err) { ret =3D CMD_RET_FAILURE; goto out; @@ -549,8 +562,8 @@ static int do_cfgblock(cmd_tbl_t *cmdtp, int flag, int = argc, } =20 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" ); --=20 2.20.1