[PATCH] cmd: spi: Judge the number of added parameters

chenzhipeng chenzhipeng at eswincomputing.com
Tue Dec 6 10:24:38 CET 2022


When only sspi is entered, help information can be printed.

Signed-off-by: chenzhipeng <chenzhipeng at eswincomputing.com>
---
 cmd/spi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/spi.c b/cmd/spi.c
index 454ebe37d7..f30018f33b 100644
--- 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);
-- 
2.25.1



More information about the U-Boot mailing list