]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: spi: Judge the number of added parameters
authorchenzhipeng <chenzhipeng@eswincomputing.com>
Tue, 6 Dec 2022 09:24:38 +0000 (17:24 +0800)
committerTom Rini <trini@konsulko.com>
Thu, 12 Jan 2023 16:25:17 +0000 (11:25 -0500)
When only sspi is entered, help information can be printed.

Signed-off-by: chenzhipeng <chenzhipeng@eswincomputing.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/spi.c

index 454ebe37d7547a1ac38e6275bee47729904c0461..f30018f33be81e0f7949f711aff02e9ce6beb3ec 100644 (file)
--- a/cmd/spi.c
+++ b/cmd/spi.c
@@ -112,6 +112,9 @@ int do_spi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
        if ((flag & CMD_FLAG_REPEAT) == 0)
        {
+               if (argc < 2)
+                       return CMD_RET_USAGE;
+
                if (argc >= 2) {
                        mode = CONFIG_DEFAULT_SPI_MODE;
                        bus = dectoul(argv[1], &cp);