mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 18:55:24 +00:00
tpm2: refactor tpm2 return value processing
There is no point in checking and reporting error code in each function calling tpm_process_command(), let's do it in one place for all commands. BRANCH=none BUG=chrome-os-partner:50645 TEST=Kevin still boots to chrome os Change-Id: I10f45bd15df293f63401c295c5dce833543c50da Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358174 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Darren Krahn <dkrahn@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
25589e5a1e
commit
452973e5f4
@@ -10,11 +10,13 @@
|
|||||||
#include "tpm2_marshaling.h"
|
#include "tpm2_marshaling.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
static void *tpm_process_command(TPM_CC command, void *command_body)
|
static struct tpm2_response *tpm_process_command(TPM_CC command,
|
||||||
|
void *command_body)
|
||||||
{
|
{
|
||||||
/* Command/response buffer. */
|
/* Command/response buffer. */
|
||||||
static uint8_t cr_buffer[TPM_BUFFER_SIZE];
|
static uint8_t cr_buffer[TPM_BUFFER_SIZE];
|
||||||
uint32_t out_size, in_size;
|
uint32_t out_size, in_size;
|
||||||
|
struct tpm2_response *response;
|
||||||
|
|
||||||
out_size = tpm_marshal_command(command, command_body,
|
out_size = tpm_marshal_command(command, command_body,
|
||||||
cr_buffer, sizeof(cr_buffer));
|
cr_buffer, sizeof(cr_buffer));
|
||||||
@@ -27,11 +29,16 @@ static void *tpm_process_command(TPM_CC command, void *command_body)
|
|||||||
in_size = sizeof(cr_buffer);
|
in_size = sizeof(cr_buffer);
|
||||||
if (VbExTpmSendReceive(cr_buffer, out_size,
|
if (VbExTpmSendReceive(cr_buffer, out_size,
|
||||||
cr_buffer, &in_size) != TPM_SUCCESS) {
|
cr_buffer, &in_size) != TPM_SUCCESS) {
|
||||||
VBDEBUG(("tpm transaction failed\n"));
|
VBDEBUG(("tpm transaction failed for %#x\n", command));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tpm_unmarshal_response(command, cr_buffer, in_size);
|
response = tpm_unmarshal_response(command, cr_buffer, in_size);
|
||||||
|
|
||||||
|
VBDEBUG(("%s: command %#x, return code %#x\n", __func__, command,
|
||||||
|
response ? response->hdr.tpm_code : -1));
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,8 +99,6 @@ uint32_t TlclRead(uint32_t index, void* data, uint32_t length)
|
|||||||
if (!response)
|
if (!response)
|
||||||
return TPM_E_READ_FAILURE;
|
return TPM_E_READ_FAILURE;
|
||||||
|
|
||||||
VBDEBUG(("%s:%d index %#x return code %x\n",
|
|
||||||
__FILE__, __LINE__, index, response->hdr.tpm_code));
|
|
||||||
switch (response->hdr.tpm_code) {
|
switch (response->hdr.tpm_code) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@@ -133,8 +138,5 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length)
|
|||||||
if (!response)
|
if (!response)
|
||||||
return TPM_E_WRITE_FAILURE;
|
return TPM_E_WRITE_FAILURE;
|
||||||
|
|
||||||
VBDEBUG(("%s:%d return code %x\n", __func__, __LINE__,
|
|
||||||
response->hdr.tpm_code));
|
|
||||||
|
|
||||||
return TPM_SUCCESS;
|
return TPM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user