helper/command: pass command prefix to command registration

Replace the "struct command *parent" parameter with a string that
contains the command prefix.
This abstracts the openocd code from the knowledge of the tree of
struct command.
This also makes unused the function command_find_in_context(), so
remove it.

Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5668
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
Antonio Borneo
2020-05-10 19:35:56 +02:00
parent 4289389937
commit 41c95aa4ea
7 changed files with 30 additions and 32 deletions

View File

@@ -479,8 +479,8 @@ static int nand_init(struct command_context *cmd_ctx)
{
if (!nand_devices)
return ERROR_OK;
struct command *parent = command_find_in_context(cmd_ctx, "nand");
return register_commands(cmd_ctx, parent, nand_exec_command_handlers);
return register_commands(cmd_ctx, "nand", nand_exec_command_handlers);
}
COMMAND_HANDLER(handle_nand_init_command)

View File

@@ -109,7 +109,6 @@ static const struct command_registration esirisc_flash_command_handlers[];
FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command)
{
struct esirisc_flash_bank *esirisc_info;
struct command *esirisc_cmd;
if (CMD_ARGC < 9)
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -123,8 +122,7 @@ FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command)
bank->driver_priv = esirisc_info;
/* register commands using existing esirisc context */
esirisc_cmd = command_find_in_context(CMD_CTX, "esirisc");
register_commands(CMD_CTX, esirisc_cmd, esirisc_flash_command_handlers);
register_commands(CMD_CTX, "esirisc", esirisc_flash_command_handlers);
return ERROR_OK;
}

View File

@@ -1248,8 +1248,7 @@ static int flash_init_drivers(struct command_context *cmd_ctx)
if (!flash_bank_list())
return ERROR_OK;
struct command *parent = command_find_in_context(cmd_ctx, "flash");
return register_commands(cmd_ctx, parent, flash_exec_command_handlers);
return register_commands(cmd_ctx, "flash", flash_exec_command_handlers);
}
COMMAND_HANDLER(handle_flash_bank_command)