cmd_fpga: cleanup help and check parameters

The usage and help for the fpga command is wrong and incomplete,
and the parameters are not checked before to be passed to the
underlying subfunction.

Signed-off-by: Stefano Babic <sbabic@denx.de>
This commit is contained in:
Stefano Babic 2010-10-19 09:22:52 +02:00 committed by Wolfgang Denk
parent c56ded6a6e
commit a790b5b232

View file

@ -163,6 +163,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
char *devstr = getenv ("fpga"); char *devstr = getenv ("fpga");
char *datastr = getenv ("fpgadata"); char *datastr = getenv ("fpgadata");
int rc = FPGA_FAIL; int rc = FPGA_FAIL;
int wrong_parms = 0;
#if defined (CONFIG_FIT) #if defined (CONFIG_FIT)
const char *fit_uname = NULL; const char *fit_uname = NULL;
ulong fit_addr; ulong fit_addr;
@ -229,6 +230,32 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
break; break;
} }
if (dev == FPGA_INVALID_DEVICE) {
puts("FPGA device not specified\n");
op = FPGA_NONE;
}
switch (op) {
case FPGA_NONE:
case FPGA_INFO:
break;
case FPGA_LOAD:
case FPGA_LOADB:
case FPGA_DUMP:
if (!fpga_data || !data_size)
wrong_parms = 1;
break;
case FPGA_LOADMK:
if (!fpga_data)
wrong_parms = 1;
break;
}
if (wrong_parms) {
puts("Wrong parameters for FPGA request\n");
op = FPGA_NONE;
}
switch (op) { switch (op) {
case FPGA_NONE: case FPGA_NONE:
return cmd_usage(cmdtp); return cmd_usage(cmdtp);
@ -343,13 +370,14 @@ static int fpga_get_op (char *opstr)
U_BOOT_CMD (fpga, 6, 1, do_fpga, U_BOOT_CMD (fpga, 6, 1, do_fpga,
"loadable FPGA image support", "loadable FPGA image support",
"fpga [operation type] [device number] [image address] [image size]\n" "[operation type] [device number] [image address] [image size]\n"
"fpga operations:\n" "fpga operations:\n"
"\tinfo\tlist known device information\n" " dump\t[dev]\t\t\tLoad device to memory buffer\n"
"\tload\tLoad device from memory buffer\n" " info\t[dev]\t\t\tlist known device information\n"
"\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n" " load\t[dev] [address] [size]\tLoad device from memory buffer\n"
"\tloadmk\tLoad device generated with mkimage\n" " loadb\t[dev] [address] [size]\t"
"\tdump\tLoad device to memory buffer" "Load device from bitstream buffer (Xilinx only)\n"
" loadmk [dev] [address]\tLoad device generated with mkimage"
#if defined(CONFIG_FIT) #if defined(CONFIG_FIT)
"\n" "\n"
"\tFor loadmk operating on FIT format uImage address must include\n" "\tFor loadmk operating on FIT format uImage address must include\n"