mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-17 22:49:02 +00:00
cmd: fpga: Reorder the arguments parsing code
This patch modifies the arguments parsing code by parsing based on requested operation for fpga loadfs and then parses the most common/basic args for other fpga load commands. This makes it easy for new command extensions or additions especially the commands with more args. Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
parent
843337089e
commit
f5953610bf
1 changed files with 19 additions and 12 deletions
31
cmd/fpga.c
31
cmd/fpga.c
|
@ -60,15 +60,31 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||||
if (datastr)
|
if (datastr)
|
||||||
fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
|
fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
|
||||||
|
|
||||||
switch (argc) {
|
if (argc > 9 || argc < 2) {
|
||||||
|
debug("%s: Too many or too few args (%d)\n", __func__, argc);
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
op = (int)fpga_get_op(argv[1]);
|
||||||
|
|
||||||
|
switch (op) {
|
||||||
#if defined(CONFIG_CMD_FPGA_LOADFS)
|
#if defined(CONFIG_CMD_FPGA_LOADFS)
|
||||||
case 9:
|
case FPGA_LOADFS:
|
||||||
|
if (argc < 9)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
fpga_fsinfo.blocksize = (unsigned int)
|
fpga_fsinfo.blocksize = (unsigned int)
|
||||||
simple_strtoul(argv[5], NULL, 16);
|
simple_strtoul(argv[5], NULL, 16);
|
||||||
fpga_fsinfo.interface = argv[6];
|
fpga_fsinfo.interface = argv[6];
|
||||||
fpga_fsinfo.dev_part = argv[7];
|
fpga_fsinfo.dev_part = argv[7];
|
||||||
fpga_fsinfo.filename = argv[8];
|
fpga_fsinfo.filename = argv[8];
|
||||||
|
argc = 5;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (argc) {
|
||||||
case 5: /* fpga <op> <dev> <data> <datasize> */
|
case 5: /* fpga <op> <dev> <data> <datasize> */
|
||||||
data_size = simple_strtoul(argv[4], NULL, 16);
|
data_size = simple_strtoul(argv[4], NULL, 16);
|
||||||
|
|
||||||
|
@ -117,15 +133,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||||
__func__, (ulong)fpga_data);
|
__func__, (ulong)fpga_data);
|
||||||
dev = FPGA_INVALID_DEVICE; /* reset device num */
|
dev = FPGA_INVALID_DEVICE; /* reset device num */
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2: /* fpga <op> */
|
|
||||||
op = (int)fpga_get_op(argv[1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug("%s: Too many or too few args (%d)\n", __func__, argc);
|
|
||||||
op = FPGA_NONE; /* force usage display */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev == FPGA_INVALID_DEVICE) {
|
if (dev == FPGA_INVALID_DEVICE) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue