cmd/sbi: error message for failure to get spec version
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 4 Oct 2022 08:09:53 +0000 (10:09 +0200)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 20 Oct 2022 07:22:15 +0000 (15:22 +0800)
If calling 'Get SBI specification version' fails, write an error message
and return CMD_RET_FAILURE.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Rick Chen <rick@andestech.com>
cmd/riscv/sbi.c

index 9bbe7d4b906db1cc171c141ba6cb537cba68b82f..24955d2be1932a7503fe952cdc3a843540c88d36 100644 (file)
@@ -56,8 +56,11 @@ static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
        long mvendorid, marchid, mimpid;
 
        ret = sbi_get_spec_version();
-       if (ret >= 0)
-               printf("SBI %ld.%ld", ret >> 24, ret & 0xffffff);
+       if (ret < 0) {
+               printf("No SBI 0.2+\n");
+               return CMD_RET_FAILURE;
+       }
+       printf("SBI %ld.%ld", ret >> 24, ret & 0xffffff);
        impl_id = sbi_get_impl_id();
        if (impl_id >= 0) {
                for (i = 0; i < ARRAY_SIZE(implementations); ++i) {