summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@bootlin.com>2018-12-03 22:54:20 +0100
committerTom Rini <trini@konsulko.com>2019-01-15 15:28:54 -0500
commit80a48dd47e3bf3ede676fae5a630cb6c80de3e69 (patch)
treea31c7ac2e2b5f238dd127b8b7c86c199452d2adb /cmd
parent6fb61445bb28a37397fdce5cb2d3f5ffd0e1a4e4 (diff)
common: command: Rework the 'cmd is repeatable' logic
The repeatable property is currently attached to the main command and sub-commands have no way to change the repeatable value (the ->repeatable field in sub-command entries is ignored). Replace the ->repeatable field by an extended ->cmd() hook (called ->cmd_rep()) which takes a new int pointer to store the repeatable cap of the command being executed. With this trick, we can let sub-commands decide whether they are repeatable or not. We also patch mmc and dtimg who are testing the ->repeatable field directly (they now use cmd_is_repeatable() instead), and fix the help entry manually since it doesn't use the U_BOOT_CMD() macro. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dtimg.c2
-rw-r--r--cmd/help.c2
-rw-r--r--cmd/mmc.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/cmd/dtimg.c b/cmd/dtimg.c
index 65c8d101b9..ae7d82f26d 100644
--- a/cmd/dtimg.c
+++ b/cmd/dtimg.c
@@ -116,7 +116,7 @@ static int do_dtimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (!cp || argc > cp->maxargs)
return CMD_RET_USAGE;
- if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+ if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
return CMD_RET_SUCCESS;
return cp->cmd(cmdtp, flag, argc, argv);
diff --git a/cmd/help.c b/cmd/help.c
index 503fa632e7..fa2010c67e 100644
--- a/cmd/help.c
+++ b/cmd/help.c
@@ -29,7 +29,7 @@ U_BOOT_CMD(
/* This does not use the U_BOOT_CMD macro as ? can't be used in symbol names */
ll_entry_declare(cmd_tbl_t, question_mark, cmd) = {
- "?", CONFIG_SYS_MAXARGS, 1, do_help,
+ "?", CONFIG_SYS_MAXARGS, cmd_always_repeatable, do_help,
"alias for 'help'",
#ifdef CONFIG_SYS_LONGHELP
""
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 9951315f91..8bc3648193 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -256,7 +256,7 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
if (cp == NULL || argc > cp->maxargs)
return CMD_RET_USAGE;
- if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+ if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
return CMD_RET_SUCCESS;
mmc = init_mmc_device(curr_device, false);
@@ -916,7 +916,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (cp == NULL || argc > cp->maxargs)
return CMD_RET_USAGE;
- if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+ if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
return CMD_RET_SUCCESS;
if (curr_device < 0) {