]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tpm: Make use of TPM2_ALG_INVAL from enum
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Mon, 30 Jun 2025 10:23:40 +0000 (11:23 +0100)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Tue, 1 Jul 2025 05:46:38 +0000 (08:46 +0300)
Now that the enum includes TPM2_ALG_INVAL, use that name in the
code.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
cmd/tpm-v2.c
lib/tpm-v2.c

index a62862e94f91320a8a222c3cefea89f0722e0862..346e21d27bb41bd20286831d4b5519e5a9f66a28 100644 (file)
@@ -113,7 +113,7 @@ static int do_tpm2_pcr_extend(struct cmd_tbl *cmdtp, int flag, int argc,
                return CMD_RET_USAGE;
        if (argc == 4) {
                algo = tpm2_name_to_algorithm(argv[3]);
-               if (algo < 0)
+               if (algo == TPM2_ALG_INVAL)
                        return CMD_RET_FAILURE;
        }
        algo_len = tpm2_algorithm_to_len(algo);
@@ -157,7 +157,7 @@ static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc,
                return CMD_RET_USAGE;
        if (argc == 4) {
                algo = tpm2_name_to_algorithm(argv[3]);
-               if (algo < 0)
+               if (algo == TPM2_ALG_INVAL)
                        return CMD_RET_FAILURE;
        }
        algo_len = tpm2_algorithm_to_len(algo);
@@ -288,7 +288,7 @@ static int do_tpm2_pcrallocate(struct cmd_tbl *cmdtp, int flag, int argc,
                return CMD_RET_USAGE;
 
        algo = tpm2_name_to_algorithm(argv[1]);
-       if (algo == -EINVAL)
+       if (algo == TPM2_ALG_INVAL)
                return CMD_RET_USAGE;
 
        ret = get_tpm(&dev);
index 9ca7933c094524f2bdb54c2a541ce6467edf8b65..5b21c57ae421eb393a3190f18812b7d7d098f57d 100644 (file)
@@ -1141,7 +1141,7 @@ enum tpm2_algorithms tpm2_name_to_algorithm(const char *name)
        }
        printf("%s: unsupported algorithm %s\n", __func__, name);
 
-       return -EINVAL;
+       return TPM2_ALG_INVAL;
 }
 
 const char *tpm2_algorithm_name(enum tpm2_algorithms algo)