cmd: simplify do_spi_flash()
CMD_RET_USAGE == -1. The special handling of this value at the end of do_spi_flash() does not make any sense. To avoid future confusion use the CMD_RET_* constants and simplify the code. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
parent
fa3b38d4c4
commit
8c8df67609
19
cmd/sf.c
19
cmd/sf.c
|
|
@ -579,21 +579,19 @@ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
||||||
/* need at least two arguments */
|
/* need at least two arguments */
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
goto usage;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
cmd = argv[1];
|
cmd = argv[1];
|
||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++argv;
|
||||||
|
|
||||||
if (strcmp(cmd, "probe") == 0) {
|
if (strcmp(cmd, "probe") == 0)
|
||||||
ret = do_spi_flash_probe(argc, argv);
|
return do_spi_flash_probe(argc, argv);
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The remaining commands require a selected device */
|
/* The remaining commands require a selected device */
|
||||||
if (!flash) {
|
if (!flash) {
|
||||||
puts("No SPI flash selected. Please run `sf probe'\n");
|
puts("No SPI flash selected. Please run `sf probe'\n");
|
||||||
return 1;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0 ||
|
if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0 ||
|
||||||
|
|
@ -606,14 +604,9 @@ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test"))
|
else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test"))
|
||||||
ret = do_spi_flash_test(argc, argv);
|
ret = do_spi_flash_test(argc, argv);
|
||||||
else
|
else
|
||||||
ret = -1;
|
ret = CMD_RET_USAGE;
|
||||||
|
|
||||||
done:
|
return ret;
|
||||||
if (ret != -1)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
usage:
|
|
||||||
return CMD_RET_USAGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_LONGHELP
|
#ifdef CONFIG_SYS_LONGHELP
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue