aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Carvalho <cclaudio@linux.vnet.ibm.com>2016-11-28 01:08:12 -0200
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-11-29 18:33:13 +1100
commit4c688b870bd62f0cdc92ea2d7ed167f6f9fd24c4 (patch)
tree9e3839b611643ddfc57ef630ca4235d3e18acbe4
parentd1886104afe2148bfd7ee6faf8cf6fb78bd4ccb4 (diff)
downloadskiboot-4c688b870bd62f0cdc92ea2d7ed167f6f9fd24c4.zip
skiboot-4c688b870bd62f0cdc92ea2d7ed167f6f9fd24c4.tar.gz
skiboot-4c688b870bd62f0cdc92ea2d7ed167f6f9fd24c4.tar.bz2
tpm_i2c_nuvoton: cleanup variables in tpm_read_fifo()
The tpm_read_fifo() has unnecessary and not so intuitive variables. This cleans up these variables. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> (cherry picked from commit 9d68320aa66c5ea274b736a7f4f757c907353bc4) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--libstb/drivers/tpm_i2c_nuvoton.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c
index e453b7c..a4cc371 100644
--- a/libstb/drivers/tpm_i2c_nuvoton.c
+++ b/libstb/drivers/tpm_i2c_nuvoton.c
@@ -357,44 +357,38 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
{
int rc, burst_count;
- size_t curByte = 0;
- uint8_t* bytePtr = (uint8_t*)buf;
- uint8_t* curBytePtr = NULL;
+ size_t count;
rc = tpm_wait_for_data_avail();
if (rc < 0)
goto error;
+ count = 0;
do {
burst_count = tpm_read_burst_count();
if (burst_count < 0) {
rc = burst_count;
goto error;
}
- /* Buffer overflow check */
- if (curByte + burst_count > *buflen)
- {
+ if (count + burst_count > *buflen) {
/**
- * @fwts-label TPMReadFifoOverflow1
+ * @fwts-label TPMReadFifoOverflow
* @fwts-advice The read from TPM FIFO overflowed. It is
* expecting more data even though we think we are done.
* This indicates a bug in the TPM device driver.
*/
- prlog(PR_ERR, "TPM: read FIFO overflow1\n");
+ prlog(PR_ERR, "NUVOTON: overflow on fifo read, c=%zd, "
+ "bc=%d, bl=%zd\n", count, burst_count, *buflen);
rc = STB_TPM_OVERFLOW;
}
- /*
- * Read some data
- */
- curBytePtr = &(bytePtr[curByte]);
rc = tpm_i2c_request_send(tpm_device->bus_id,
tpm_device->xscom_base,
SMBUS_READ,
TPM_DATA_FIFO_R, 1,
- curBytePtr, burst_count);
- curByte += burst_count;
- DBG("%s read FIFO. received %zd bytes, rc=%d\n",
- (rc) ? "!!!!" : "----", curByte, rc);
+ &buf[count], burst_count);
+ count += burst_count;
+ DBG("%s FIFO: %d bytes read, count=%zd, rc=%d\n",
+ (rc) ? "!!!!" : "----", burst_count, count, rc);
if (rc < 0)
goto error;
rc = tpm_wait_for_fifo_status(
@@ -404,7 +398,7 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
goto error;
} while (rc == 0);
- *buflen = curByte;
+ *buflen = count;
return 0;
error: