From 0427b9c52578b2bb0dc1a3058d732899d107f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 16 Oct 2016 17:13:55 +0200 Subject: cmd/tpm_test: Fix misleading code indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 6.2 reasonably complains about the current code: ../cmd/tpm_test.c: In function ‘do_tpmtest’: ../cmd/tpm_test.c:540:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] for (i = 0; i < argc; i++) ^~~ ../cmd/tpm_test.c:542:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’ printf("\n------\n"); ^~~~~~ Signed-off-by: Stefan Brüns Reviewed-by: Simon Glass Updated to remove C99 variable decl: Signed-off-by: Simon Glass --- cmd/tpm_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c index 65332d1..3306405 100644 --- a/cmd/tpm_test.c +++ b/cmd/tpm_test.c @@ -532,15 +532,15 @@ static cmd_tbl_t cmd_cros_tpm_sub[] = { static int do_tpmtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *c; + int i; printf("argc = %d, argv = ", argc); - do { - int i = 0; - for (i = 0; i < argc; i++) - printf(" %s", argv[i]); - printf("\n------\n"); - } while (0); + for (i = 0; i < argc; i++) + printf(" %s", argv[i]); + + printf("\n------\n"); + argc--; argv++; c = find_cmd_tbl(argv[0], cmd_cros_tpm_sub, -- cgit v1.1 From f7f191ee41c0590917f4a969b569af0a01106380 Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Thu, 24 Nov 2016 15:02:18 +0100 Subject: cmd/fdt: fix uncallable systemsetup command The function that is processing the 'fdt' parameters is one big if-else if. In order to be able to type command faster only the first few letter are checked to know which block of code to execute. For systemsetup, the block of code that was executed was always the wrong one and ended up in a failure. } else if (argv[1][0] == 's') { process "fdt set" command } else if (strncmp(argv[1], "sys", 3) == 0) { process "fdt systemsetup" command. } When typing "fdt systemsetup", the code that was executed was the code for "fdt set". This commit fix this issue by moving the "else if" for systemsetup before the else if for "fdt set". This allow us to keep compatibility with any script that make use of "fdt s" to set node values. Signed-off-by: Fabien Parent Acked-by: Simon Glass --- cmd/fdt.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'cmd') diff --git a/cmd/fdt.c b/cmd/fdt.c index b503357..8bd345a 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -206,7 +206,17 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } working_fdt = newaddr; +#ifdef CONFIG_OF_SYSTEM_SETUP + /* Call the board-specific fixup routine */ + } else if (strncmp(argv[1], "sys", 3) == 0) { + int err = ft_system_setup(working_fdt, gd->bd); + if (err) { + printf("Failed to add system information to FDT: %s\n", + fdt_strerror(err)); + return CMD_RET_FAILURE; + } +#endif /* * Make a new node */ @@ -577,18 +587,6 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } } #endif -#ifdef CONFIG_OF_SYSTEM_SETUP - /* Call the board-specific fixup routine */ - else if (strncmp(argv[1], "sys", 3) == 0) { - int err = ft_system_setup(working_fdt, gd->bd); - - if (err) { - printf("Failed to add system information to FDT: %s\n", - fdt_strerror(err)); - return CMD_RET_FAILURE; - } - } -#endif /* Create a chosen node */ else if (strncmp(argv[1], "cho", 3) == 0) { unsigned long initrd_start = 0, initrd_end = 0; -- cgit v1.1 From a2558e8729831e0bcef634ea2440e60425ef0ff6 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Thu, 3 Nov 2016 08:53:52 -0600 Subject: cmd: crosec: Move cros_ec_decode_region helper to cmd/cros_ec.c The cros_ec_decode_region() function is only used in combination with the crosec cmds. Move the function to the correct place. Signed-off-by: Moritz Fischer Cc: Simon Glass Cc: Masahiro Yamada Cc: u-boot@lists.denx.de Acked-by: Simon Glass --- cmd/cros_ec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cmd') diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c index abf11f0..9d42f87 100644 --- a/cmd/cros_ec.c +++ b/cmd/cros_ec.c @@ -20,6 +20,29 @@ static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"}; DECLARE_GLOBAL_DATA_PTR; /** + * Decode a flash region parameter + * + * @param argc Number of params remaining + * @param argv List of remaining parameters + * @return flash region (EC_FLASH_REGION_...) or -1 on error + */ +static int cros_ec_decode_region(int argc, char * const argv[]) +{ + if (argc > 0) { + if (0 == strcmp(*argv, "rw")) + return EC_FLASH_REGION_RW; + else if (0 == strcmp(*argv, "ro")) + return EC_FLASH_REGION_RO; + + debug("%s: Invalid region '%s'\n", __func__, *argv); + } else { + debug("%s: Missing region parameter\n", __func__); + } + + return -1; +} + +/** * Perform a flash read or write command * * @param dev CROS-EC device to read/write -- cgit v1.1