command: Introduce functions to obtain command arguments

Add some functions which provide an argument to a command, or NULL if
the argument does not exist.

Use the same numbering as argv[] since it seems less confusing than the
previous idea.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Simon Glass
2023-11-18 14:05:20 -07:00
committed by Tom Rini
parent 1047b5340c
commit 8632b36b96
10 changed files with 49 additions and 16 deletions

View File

@@ -40,8 +40,8 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL,
&dev_desc, &info, 1);
part = blk_get_device_part_str(intf, cmd_arg2(argc, argv),
&dev_desc, &info, 1);
if (part < 0) {
bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
return 1;