aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Carvalho <cclaudio@linux.vnet.ibm.com>2016-11-28 01:08:06 -0200
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-11-29 18:17:02 +1100
commit71b88229c99c36ccfdbaaa50c851343f95c24320 (patch)
treee1bbded41fdb78b774f5b4c269c46abf3afd8415
parentcd5953d9191d508379792b3b09f00f307667984e (diff)
downloadskiboot-71b88229c99c36ccfdbaaa50c851343f95c24320.zip
skiboot-71b88229c99c36ccfdbaaa50c851343f95c24320.tar.gz
skiboot-71b88229c99c36ccfdbaaa50c851343f95c24320.tar.bz2
tpm_i2c_nuvoton: return burst_count in tpm_read_burst_count()
This returns burst_count as opposed to pass it as a parameter. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--libstb/drivers/tpm_i2c_nuvoton.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c
index eb96f5e..0c99431 100644
--- a/libstb/drivers/tpm_i2c_nuvoton.c
+++ b/libstb/drivers/tpm_i2c_nuvoton.c
@@ -215,22 +215,20 @@ static int tpm_poll_for_data_avail(void)
return STB_TPM_TIMEOUT;
}
-static int tpm_read_burst_count(uint8_t* burst_count)
+static int tpm_read_burst_count(void)
{
int rc, delay;
- uint8_t bc;
+ uint8_t burst_count;
+ burst_count = 0;
delay = 0;
- *burst_count = 0;
-
do {
/* In i2C, burstCount is 1 byte */
- rc = tpm_status_read_byte(TPM_BURST_COUNT, &bc);
- if (rc == 0 && bc > 0) {
- DBG("---- burst_count=%d, delay=%d/%d\n",
+ rc = tpm_status_read_byte(TPM_BURST_COUNT, &burst_count);
+ if (rc == 0 && burst_count > 0) {
+ DBG("---- burst_count=%d, delay=%d/%d\n", burst_count,
delay, TPM_TIMEOUT_D);
- *burst_count = bc;
- return 0;
+ return (int) burst_count;
}
if (rc < 0) {
/**
@@ -261,8 +259,7 @@ static int tpm_read_burst_count(uint8_t* burst_count)
static int tpm_write_fifo(uint8_t* buf, size_t buflen)
{
- uint8_t burst_count = 0;
- int rc;
+ int rc, burst_count;
size_t curByte = 0;
uint8_t* bytePtr = buf;
uint8_t* curBytePtr = NULL;
@@ -275,9 +272,9 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
size_t tx_len = 0;
do {
- rc = tpm_read_burst_count(&burst_count);
- if (rc < 0)
- return rc;
+ burst_count = tpm_read_burst_count();
+ if (burst_count < 0)
+ return burst_count;
/*
* Send in some data
*/
@@ -309,9 +306,9 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
/*
* Send the final byte
*/
- rc = tpm_read_burst_count(&burst_count);
- if (rc < 0)
- return rc;
+ burst_count = tpm_read_burst_count();
+ if (burst_count < 0)
+ return burst_count;
curBytePtr = &(bytePtr[curByte]);
rc = tpm_i2c_request_send(tpm_device->bus_id,
tpm_device->xscom_base,
@@ -339,8 +336,7 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen)
static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
{
- int rc;
- uint8_t burst_count;
+ int rc, burst_count;
size_t curByte = 0;
uint8_t* bytePtr = (uint8_t*)buf;
uint8_t* curBytePtr = NULL;
@@ -350,9 +346,11 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
goto error;
do {
- rc = tpm_read_burst_count(&burst_count);
- if (rc < 0)
+ burst_count = tpm_read_burst_count();
+ if (burst_count < 0) {
+ rc = burst_count;
goto error;
+ }
/* Buffer overflow check */
if (curByte + burst_count > *buflen)
{