[PATCH v2 2/2] tpm: Make use of TPM2_ALG_INVAL from enum
Ilias Apalodimas
ilias.apalodimas at linaro.org
Mon Jun 30 09:23:56 CEST 2025
On Fri, 27 Jun 2025 at 12:37, Andrew Goodbody
<andrew.goodbody at linaro.org> wrote:
>
> Now that the enum includes TPM2_ALG_INVAL, use that name in the
> code.
>
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
> cmd/tpm-v2.c | 6 +++---
> lib/tpm-v2.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
> index a62862e94f9..346e21d27bb 100644
> --- a/cmd/tpm-v2.c
> +++ b/cmd/tpm-v2.c
> @@ -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);
> diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
> index 9ca7933c094..5b21c57ae42 100644
> --- a/lib/tpm-v2.c
> +++ b/lib/tpm-v2.c
> @@ -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)
>
> --
> 2.39.5
>
More information about the U-Boot
mailing list