Skip to content

Commit 31dd0a0

Browse files
ycsingithub-actions[bot]
authored andcommitted
shell: devmem: minor optimizations
- Use `SHELL_CMD_ARG_REGISTER` for the main cmd to state the required number of arguments, this helps to remove the runtime check from the command, and also print the help message to the terminal when the argument count is unexpected. - Some changes to the help text that hopefully makes the mandatory and optional arguments more obvious to the user Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]> (cherry picked from commit 276ccd0)
1 parent e84c516 commit 31dd0a0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

subsys/shell/modules/devmem_service.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ static int cmd_devmem(const struct shell *sh, size_t argc, char **argv)
315315
uint32_t value = 0;
316316
uint8_t width;
317317

318-
if (argc < 2 || argc > 4) {
319-
return -EINVAL;
320-
}
321-
322318
phys_addr = strtoul(argv[1], NULL, 16);
323319

324320
#if defined(CONFIG_MMU) || defined(CONFIG_PCIE)
@@ -365,11 +361,11 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_devmem,
365361
cmd_load, 2, 1),
366362
SHELL_SUBCMD_SET_END);
367363

368-
SHELL_CMD_REGISTER(devmem, &sub_devmem,
364+
SHELL_CMD_ARG_REGISTER(devmem, &sub_devmem,
369365
"Read/write physical memory\n"
370366
"Usage:\n"
371367
"Read memory at address with optional width:\n"
372-
"devmem address [width]\n"
368+
"devmem <address> [<width>]\n"
373369
"Write memory at address with mandatory width and value:\n"
374-
"devmem address <width> <value>",
375-
cmd_devmem);
370+
"devmem <address> <width> <value>",
371+
cmd_devmem, 2, 2);

0 commit comments

Comments
 (0)