Commit 480fa71c authored by Yong Cong Sin's avatar Yong Cong Sin Committed by Anas Nashif
Browse files

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: default avatarYong Cong Sin <ycsin@meta.com>
Signed-off-by: default avatarYong Cong Sin <yongcong.sin@gmail.com>
(cherry picked from commit 276ccd04)
parent 05acdcfb
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -315,10 +315,6 @@ static int cmd_devmem(const struct shell *sh, size_t argc, char **argv)
	uint32_t value = 0;
	uint8_t width;

	if (argc < 2 || argc > 4) {
		return -EINVAL;
	}

	phys_addr = strtoul(argv[1], NULL, 16);

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

SHELL_CMD_REGISTER(devmem, &sub_devmem,
SHELL_CMD_ARG_REGISTER(devmem, &sub_devmem,
		   "Read/write physical memory\n"
		   "Usage:\n"
		   "Read memory at address with optional width:\n"
		   "devmem address [width]\n"
		   "devmem <address> [<width>]\n"
		   "Write memory at address with mandatory width and value:\n"
		   "devmem address <width> <value>",
		   cmd_devmem);
		   "devmem <address> <width> <value>",
		   cmd_devmem, 2, 2);