From d1886104afe2148bfd7ee6faf8cf6fb78bd4ccb4 Mon Sep 17 00:00:00 2001 From: Claudio Carvalho Date: Mon, 28 Nov 2016 01:08:11 -0200 Subject: [PATCH] tpm_i2c_nuvoton: handle errors after writting the tpm fifo This adds code to handle errors after writting the tpm fifo in tpm_write_fifo(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho Signed-off-by: Stewart Smith (cherry picked from commit 0eb2fc7aa4fdd86876bf1663def0f91b1328b0be) Signed-off-by: Stewart Smith --- libstb/drivers/tpm_i2c_nuvoton.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c index 28df2c78f381..e453b7c33007 100644 --- a/libstb/drivers/tpm_i2c_nuvoton.c +++ b/libstb/drivers/tpm_i2c_nuvoton.c @@ -279,8 +279,17 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen) count += bytes; DBG("%s FIFO: %zd bytes written, count=%zd, rc=%d\n", (rc) ? "!!!!" : "----", bytes, count, rc); - if (rc < 0) - return rc; + if (rc < 0) { + /** + * @fwts-label TPMWriteFifo + * @fwts-advice Either the tpm device or the tpm-i2c + * interface doesn't seem to be working properly. Check + * the return code (rc) for further details. + */ + prlog(PR_ERR, "NUVOTON: fail to write fifo, " + "count=%zd, rc=%d\n", count, rc); + return STB_DRIVER_ERROR; + } rc = tpm_wait_for_fifo_status(TPM_STS_VALID | TPM_STS_EXPECT, TPM_STS_VALID | TPM_STS_EXPECT);