diff options
author | Jon Murphy <jpmurphy@google.com> | 2023-09-05 11:36:43 -0600 |
---|---|---|
committer | Raul Rangel <rrangel@chromium.org> | 2023-09-28 16:54:37 +0000 |
commit | d7b8dc9cf5978809912dcffefce2eda5937c9653 (patch) | |
tree | 56befbc9563ce2baca6f31ccbfb041e99fb858d6 /src/drivers/spi/tpm/tis.c | |
parent | 53fc667943052bd592b8406bdf4bf652c6c9cd3a (diff) |
treewide: convert to tpm_result_t
Convert TPM functions to return TPM error codes(referred to as
tpm_result_t) values to match the TCG standard.
BUG=b:296439237
TEST=build and boot to Skyrim
BRANCH=None
Change-Id: Ifdf9ff6c2a1f9b938dbb04d245799391115eb6b1
Signed-off-by: Jon Murphy <jpmurphy@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77666
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/spi/tpm/tis.c')
-rw-r--r-- | src/drivers/spi/tpm/tis.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index b9b2a4a5cb..6fa6c82848 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -29,29 +29,31 @@ static const char *tis_get_dev_name(struct tpm2_info *info) return "Unknown"; } -int tis_open(void) +tpm_result_t tis_open(void) { if (tpm_is_open) { printk(BIOS_ERR, "%s() called twice.\n", __func__); - return -1; + return TPM_CB_FAIL; } - return 0; + return TPM_SUCCESS; } -int tis_init(void) +tpm_result_t tis_init(void) { struct spi_slave spi; struct tpm2_info info; + tpm_result_t rc = TPM_SUCCESS; if (spi_setup_slave(CONFIG_DRIVER_TPM_SPI_BUS, CONFIG_DRIVER_TPM_SPI_CHIP, &spi)) { printk(BIOS_ERR, "Failed to setup TPM SPI slave\n"); - return -1; + return TPM_CB_FAIL; } - if (tpm2_init(&spi)) { + rc = tpm2_init(&spi); + if (rc) { printk(BIOS_ERR, "Failed to initialize TPM SPI interface\n"); - return -1; + return rc; } tpm2_get_info(&info); @@ -59,18 +61,18 @@ int tis_init(void) printk(BIOS_INFO, "Initialized TPM device %s revision %d\n", tis_get_dev_name(&info), info.revision); - return 0; + return TPM_SUCCESS; } -int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, +tpm_result_t tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf, size_t *rbuf_len) { int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len); if (len == 0) - return -1; + return TPM_CB_FAIL; *rbuf_len = len; - return 0; + return TPM_SUCCESS; } |