diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2023-01-02 18:21:15 +0100 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2023-01-26 21:04:40 +0530 |
commit | 8c8df676095ea05290f3deff1c8449f82e52b6ed (patch) | |
tree | 061d7efffacd4aa97b6ae191d108c5653814dab9 | |
parent | fa3b38d4c432745b05e417c750c1c59c347fc18e (diff) | |
download | u-boot-8c8df676095ea05290f3deff1c8449f82e52b6ed.zip u-boot-8c8df676095ea05290f3deff1c8449f82e52b6ed.tar.gz u-boot-8c8df676095ea05290f3deff1c8449f82e52b6ed.tar.bz2 |
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>
-rw-r--r-- | cmd/sf.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -579,21 +579,19 @@ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc, /* need at least two arguments */ if (argc < 2) - goto usage; + return CMD_RET_USAGE; cmd = argv[1]; --argc; ++argv; - if (strcmp(cmd, "probe") == 0) { - ret = do_spi_flash_probe(argc, argv); - goto done; - } + if (strcmp(cmd, "probe") == 0) + return do_spi_flash_probe(argc, argv); /* The remaining commands require a selected device */ if (!flash) { 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 || @@ -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")) ret = do_spi_flash_test(argc, argv); else - ret = -1; - -done: - if (ret != -1) - return ret; + ret = CMD_RET_USAGE; -usage: - return CMD_RET_USAGE; + return ret; } #ifdef CONFIG_SYS_LONGHELP |