summaryrefslogtreecommitdiff
path: root/drivers/tpm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-18 14:18:00 -0600
committerSimon Glass <sjg@chromium.org>2021-08-01 09:05:24 -0600
commit7f350a959c1a9562b1b84d145e1084e90fa86353 (patch)
treea4db65d44b2e525424052e0fdf164c3c86d27938 /drivers/tpm
parentf9143c12003aabbad3a2485f8ad305f5dff5fae9 (diff)
downloadu-boot-7f350a959c1a9562b1b84d145e1084e90fa86353.tar.gz
u-boot-7f350a959c1a9562b1b84d145e1084e90fa86353.tar.bz2
u-boot-7f350a959c1a9562b1b84d145e1084e90fa86353.zip
sandbox: tpm: Correct handling of get-capability
This function current handles the kernel case incorrectly. Fix it, and use the shorter TPM_HDR_LEN while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/tpm')
-rw-r--r--drivers/tpm/tpm_tis_sandbox.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c
index 85b22afa4d..efbeb00ab6 100644
--- a/drivers/tpm/tpm_tis_sandbox.c
+++ b/drivers/tpm/tpm_tis_sandbox.c
@@ -140,16 +140,13 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
printf("Get flags index %#02x\n", index);
*recv_len = 22;
memset(recvbuf, '\0', *recv_len);
- data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
- sizeof(uint32_t);
+ data = recvbuf + TPM_HDR_LEN + sizeof(uint32_t);
switch (index) {
case FIRMWARE_NV_INDEX:
break;
case KERNEL_NV_INDEX:
handle_cap_flag_space(&data, index);
- *recv_len = data - recvbuf -
- TPM_RESPONSE_HEADER_LENGTH -
- sizeof(uint32_t);
+ *recv_len = data - recvbuf;
break;
case TPM_CAP_FLAG_PERMANENT: {
struct tpm_permanent_flags *pflags;
@@ -166,15 +163,12 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
printf(" ** Unknown flags index %x\n", index);
return -ENOSYS;
}
- put_unaligned_be32(*recv_len,
- recvbuf +
- TPM_RESPONSE_HEADER_LENGTH);
+ put_unaligned_be32(*recv_len, recvbuf + TPM_HDR_LEN);
break;
case TPM_CAP_NV_INDEX:
index = get_unaligned_be32(sendbuf + 18);
printf("Get cap nv index %#02x\n", index);
- put_unaligned_be32(22, recvbuf +
- TPM_RESPONSE_HEADER_LENGTH);
+ put_unaligned_be32(22, recvbuf + TPM_HDR_LEN);
break;
default:
printf(" ** Unknown 0x65 command type %#02x\n",